The address space of a process consists of all logical addresses that the process is allowed to use.
1. Each process address space is separate.
2. The kernel allocates logical addresses to a process in intervals called memory
regions.
Memory regions have initial logical address and a length.
Situations where process can get new memory regions : -
1. Creating a new process. ( fork() ).
2. Loading an entirely new program. ( execve() )
3. Memory mapping a file. ( mmap() ).
4. Growing its stack. ( stores local data, return addresses, used for parameter passing ).
5. Creating shared memory. ( shmat() )
6. Expanding its heap. ( malloc() ).
There are three areas where the program gets mapped into memory viz.
1. Code Segment : - Also known as the text segment.
Contains the executable instructions.
2. Data Segment : -
Three Categories :-
1. Initialized Data : - Statically allocated or global data that are initialized with
non-zero values.
2. Zero-Initialized or BSS data : - Uninitialized data.
3. Heap : - Way to allocate memory at run-time (dynamically).
3. Stack Segment : - Local variables, Function Parameters.
No comments:
Post a Comment