linux kernel - On heap/stack and OS page swapping -


i trying understand few linux-related concepts can me answer following questions.

[question i] aware compiler gives virtual address (va) program's data , code segment. os uses these va's , try fit them physical memory. elf loader (fs/binfmt_elf.c in source code) in linux. when va stack , heap gets allocated process? guess dynamic, va come segments? if possible, can point me source codes.

[question ii] while know that, physical memory limited in size. hence os has swap out pages @ times keep several processes running. when needs swap out page, pulls page memory , writes disk. agree data , code pages can written disk (perhaps written in same area came disk). can os swap out heap , stack pages well? if yes, store in disk?

question i:

you need start simplified view. question 1, think in terms of logical memory rather virtual memory. let's doing in 32bit mode, have theoretical maximum of 3/4ths of 2^32 logical memory available process.

when new process loads executable, entire address space going null. mean there no memory @ (conceptually). program loader read instructions in executable file build logical address space @ start of execution.

the loader create user stack. you've got have 1 program run. that, mean loader allocate logical pages stack.

the loader not create heap. there address range heap loader not map pages it. can explicitly map pages using system calls create pages own heap. alternatively, can call library function malloc() map pages you.

question ii:

all user pages can swapped out, including heap , stack. go page file, on linux swap partition.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -