Download presentation
Presentation is loading. Please wait.
Published byMillicent Smith Modified over 8 years ago
1
1 Structure of Processes Chapter 6 Process State and Transition Data Structure for Process Layout of System Memory THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall
2
2 Process States and Transitions 1 2 9 7 34 65 8 User Running Preempted Zombie Asleep in Memory Sleep, SwappedReady to Run, Swapped fork Created Ready to Run in Memory Kernel Running not enough mem (swapping system only) swap out swap in wakeup swap out wakeup enough mem sleep reschedule process preempt return to user system call, interrupt interrupt, interrupt return
3
3 Data Structures for Process Text Stack Data File Descriptor Table Per Process Region Table Kernel Process Table Kernel Region Table A Process U Area
4
4 Data Structure for Process (contd.) u area main memory Kernel process table per process region table Kernel region table
5
5 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
6
6 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
7
7 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.
8
8 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
9
9 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
10
10 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
11
11 Kernel Region table Kernel region table contains the pointer to the page table which keeps the physical memory address
12
12 Regions 8K 16K 32K b a d c e 4K 8K 32K Text Data Stack Text Data Stack Process A Process B Per Proc Region Tables (Virtual Addresses) Region
13
13 Pages and Page Tables Logical Page NumberPhysical Page Number 0177 1 54 2209 3 17
14
14 Pages and Page Tables (contd.) 8K 32K 64K Text Data Stack 541K 783K 986K 897K 87K 552K 727K 941K empty 137K 852K 764K................ 1096K 2001K 433K 333K................................ Per Proc Region Table Page Tables(Physical Addresses) Virtual Addresses
15
Rest of the topics in Chapter-6 6.3: Context of a Process 6.4 Saving Context of a Process 6.5 Region and related 7 algorithms 6.6 Sleep and Wakeup 15
16
6.3: Context of a Process User-level context Register-level context System-level context 16
17
User-level Context Text Data User stack Shared memory These may be in main memory or in the swap space 17
18
Register-level Context Program counter Processor Status (PS) register Stack pointer General purpose registers 18
19
System-level Context Static part –Process table entry –U area of a process –Pregion entries, region tables, page tables: Dynamic part –Kernel stack: Private copy of kernel stack (of a process) –A set of layers Each system-level context layer contains necessary info to recover previous layer (including register- level context of previous layer) 19
20
Components of Process Context 20
21
Handling Interrupts 21
22
Example of Interrupts 22
23
Algorithm for System Call 23
24
Steps for a Context Switch 24
25
6.5 Algorithms on regions Alloc Region Attach region Grow / Shrink region Load region Freeing region Detaching region Duplicating region 25
26
Region Table entry A ptr to the inode of the file whose content were originally load into the region Region type (text, data,..) Region size Location of region in PhyMem Status: Locked, in demand, valid, being loaded into memory Ref count: # of processes referencing the region 26
27
Allocating a region 27
28
Example of Attaching an Existing Text Region 28
29
Changing region size 29
30
Example: Growing stack by 1K 30
31
Loading a region 31
32
Example: Loading a text region 32
33
Freeing a region 33
34
Detaching a region 34
35
Duplicating a region 35
36
Example: Duplicating a region 36
37
Sleep and Wakeup Processes sleep on Events Events are mapped into addresses There are sleep queue based on sleep address 37
38
38
39
Sleep Alg. (1) 39
40
Sleep Alg (2) 40
41
Wakeup 41
42
Thank You 42
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.