Courses/Computer Science/CPSC 457.W2013/Lecture Notes/ProcAddrSpace

From wiki.ucalgary.ca
< Courses‎ | Computer Science‎ | CPSC 457.W2013‎ | Lecture Notes
Revision as of 06:12, 12 February 2013 by Locasto (talk | contribs) (Created page with "= 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, shar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 PDF slides from today

The code that calls sbrk() to expand the heap memory region and write to it via memset() to exhaust available memory. sample run

Sample run for activity 1

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)

Reading

  • MOS: 3.1 "No Memory Abstraction"
  • MOS: 3.2 "A Memory Abstraction: Address Spaces"