Courses/Computer Science/CPSC 457.W2013/Lecture Notes/ProcAddrSpace
The Process Address Space
We will examine the kernel's support for page tables, memory pages and how to associate them with a process. We will look at how to create, share, and delete a process address space, how to define the memory regions that compose it, and how to manage the heap.
We will draw our material from ULK, Chapter 9 and MOS, Chapter 3.
Lecture Notes
The code that calls sbrk() to expand the heap memory region and write to it via memset() to exhaust available memory. sample run
Kernel Code Links
Below I provide links to the 2.6.27.41 version of the kernel; more recent versions have slight differences in their fields.
The mm_struct declared inside task_struct (note mm and active_mm)
The actual type definition of mm_struct.
The type definition of vm_area_struct
The mprotect system call entry point. This is an example of using these vm area structure fields and properties (particularly the flags).
The allocation routine for the page table directory
Notes
- kernel / userland split
- kernel typically starts at physical address 0x00100000 (from the 2nd MB - note that this is a hex address, not a binary address; 1 x 16^5)
- _text (start of kernel code)
- _etext (end of kernel code)
- _etext+1 is start of initialized data
- _edata (end of initialized data)
- _edata+1 (start of uninitialized data)
- _end (end of uninitialized data)
- but the logical address is the "top" 1 GB of RAM (0xc0000000 to 0xffffffff)
- userland is thus in logical addresses 0x00000000 to 0xbfffffff (and if we remember what stack addresses look like from gdb, and that the stack typically grows "down" toward zero on x86, this makes sense)
- kernel typically starts at physical address 0x00100000 (from the 2nd MB - note that this is a hex address, not a binary address; 1 x 16^5)
Reading
- MOS: 3.1 "No Memory Abstraction"
- MOS: 3.2 "A Memory Abstraction: Address Spaces"