CS350 Operating Systems Fall 2007 The Kernel and System Calls 26 Summary of

Cs350 operating systems fall 2007 the kernel and

This preview shows page 53 - 57 out of 164 pages.

CS350 Operating Systems Fall 2007 The Kernel and System Calls 26 Summary of Hardware Features Used by the Kernel Interrupts and Exceptions, such as timer interrupts, give the kernel the opportunity to regain control from user programs. Memory management features, such as memory protection, allow the kernel to protect its address space from user programs. Privileged execution mode allows the kernel to reserve critical machine functions (e.g, halt) for its own use. Independent I/O devices allow the kernel to schedule other work while I/O operations are on-going. CS350 Operating Systems Fall 2007 JNTU World JNTU World Downloaded From JNTU World ()
Image of page 53
Memory Management 1 Virtual and Physical Addresses Physical addresses are provided directly by the machine. one physical address space per machine addresses typically range from some minumum (sometimes 0 ) to some maximum, though some portions of this range are usually used by the OS and/or devices, and are not available for user processes Virtual addresses (or logical addresses) are addresses provided by the OS to processes. one virtual address space per process addresses typically start at zero, but not necessarily space may consist of several segments Address translation (or address binding) means mapping virtual addresses to physical addresses. CS350 Operating Systems Fall 2007 Memory Management 2 Address Space Layout 0x0040 00b0 .rodata virtual addresses 0 stack 0x1000 0000 .data .sbss .bss .text 0x7fff ffff max Size of each section except stack is specified in ELF file Code (i.e., text), read-only data and initialized data segments are initialized from the ELF file. Remaining sections are initially zero-filled. Sections have their own specified alignment and segments are page aligned. 3 segments = (.text + .rodata), (.data + .sbss + .bss), (stack) Note: not all programs contain this many segments and sections. CS350 Operating Systems Fall 2007 JNTU World JNTU World Downloaded From JNTU World ()
Image of page 54
Memory Management 3 C Code for Sections and Segments Example #include <unistd.h> #define N (200) int x = 0xdeadbeef; int y1; int y2; int y3; int array[4096]; char const * str = "Hello World\n"; const int z = 0xabcddcba; struct example { int ypos; int xpos; }; CS350 Operating Systems Fall 2007 Memory Management 4 C Code for Sections and Segments Example (cont’d) int main() { int count = 0; const int value = 1; y1 = N; y2 = 2; count = x + y1; y2 = z + y2 + value; reboot(RB_POWEROFF); return 0; / * avoid compiler warnings * / } CS350 Operating Systems Fall 2007 JNTU World JNTU World Downloaded From JNTU World ()
Image of page 55
Memory Management 5 cs350-readelf Output: Sections and Segments % cs350-readelf -a segments > readelf.out % cat readelf.out Section Headers: [Nr] Name Type Addr Off Size ES Flg ... Al [ 0] NULL 00000000 000000 000000 00 ... 0
Image of page 56
Image of page 57

You've reached the end of your free preview.

Want to read all 164 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture