Transcript Memory Management
Chapter 6 Structure of Processes
Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall 1
Process States and Transitions
interrupt, interrupt return 9 Zombie Asleep in Memory 4 swap out 6 Sleep, Swapped sleep User Running 2 1 system call, interrupt return Kernel Running preempt reschedule process return to user Preempted 7 wakeup wakeup swap out 3 5 swap in Ready to Run in Memory enough mem Created 8 fork not enough mem (swapping system only) Ready to Run, Swapped 2
Data Structures for Process
Kernel Process Table A Process Kernel Region Table Per Process Region Table Text File Descriptor Table Data Stack U Area
3
Data Structure for Process (contd.)
u area per process region table Kernel region table Kernel process table main memory
4
State of a Process
– Process table entry • Contains general fields of processes that must be always be accessible to the kernel –
U area
• further characteristics of the process only need to be accessible to the running process itself 5
Process table entry
• State field: user running, kernel running etc.
• Fields that allow the kernel to locate the process and u area. Requires while context switch • Process size : kernel know how much space to allocate for the process.
• User ID • Process ID 6
Process table entry (contd.)
• Event descriptor.
– Used when the process is in the "sleep" state.
• Scheduling parameters.
– Allow the kernel to determine the order in which processes move to the states "kernel running" and "user running” • A signal field.
– keeps the signals sent to a process but not yet handled.
• Various timers: process execution time, resource utilization etc.
7
U Area
• A pointer to the process table entry • User IDs • various Timer: – – Execution time in user mode Execution Time in kernel mode • An error field: keeps error during system call • Return value field: result of system call 8
U Area (contd.)
• I/O parameters – Amount of data transfer – Address of source and target etc.
• The current directory and current root • User file descriptor table • Limit fields – Restrict process size – Restrict size of the file it can write • The control terminal field: – login terminal associated with the process, if one exists • An array indicates how the process wishes to react to signal 9
Per Process Region Table (Pregion) • Each pregion entry points to the kernel region table • Starting virtual (absolute) address of the region • Permission filed: – read-only, read-write, read-execute 10
Kernel Region table
• Kernel region table contains the pointer to the page table which keeps the physical memory address 11
Regions
Per Proc Region Tables (Virtual Addresses) Process A Text 8K Data 16K Stack 32K b a Process B Text 4K Data 8K Stack 32K d Region
Pages and Page Tables
Logical Page Number 0 1 2 3 Physical Page Number 177 54 209 17 13
Pages and Page Tables (contd.)
Per Proc Region Table Text 8K Data 32K Stack 64K Virtual Addresses Page Tables(Physical Addresses) 541K 783K 986K 897K .
.
.
.
.
.
.
.
87K 552K 727K 941K 1096K 2001K .
.
.
.
.
.
.
.
empty 137K 852K 764K 433K 333K .
.
.
.
.
.
.
.