230 likes | 606 Views
Structure of Processes. Process State and Transition Data Structure for Process Layout of System Memory. Chapter 6. THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall. Process States and Transitions. User Running. 1. system call, interrupt. return to user.
E N D
Structure of Processes Process State and Transition Data Structure for Process Layout of System Memory Chapter 6 THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall
Process States and Transitions User Running 1 system call, interrupt return to user interrupt, interrupt return return Preempted Kernel Running 2 7 9 preempt reschedule process Zombie sleep Ready to Run in Memory 4 3 wakeup enough mem Asleep in Memory Created fork swap out 8 swap out swap in not enough mem (swapping system only) 6 5 wakeup Sleep, Swapped Ready to Run, Swapped
Data Structures for Process Kernel Region Table Kernel Process Table A Process Per Process Region Table Text File Descriptor Table Data Stack U Area
Data Structure for Process (contd.) per process region table Kernel region table u area main memory Kernel process table
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
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
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.
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
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
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
Kernel Region table • Kernel region table contains the pointer to the page table which keeps the physical memory address
Regions Region Per Proc Region Tables (Virtual Addresses) 8K 4K b 16K 8K Text Process A 32K 32K c Data Stack a Text e Process B Data d Stack <Processes and Regions>
Pages and Page Tables Logical Page Number Physical Page Number 0 177 1 54 2 209 3 17
Pages and Page Tables (contd.) Per Proc Region Table Page Tables(Physical Addresses) 8K Text 32K empty Data 137K 64K 852K Stack 87K 764K Virtual Addresses 552K 541K 433K 727K 783K 333K 941K 986K . . . . . . . . 1096K 897K 2001K . . . . . . . . . . . . . . . . <Mapping Virtual Addresses to Physical Address>