processes and process control 1. processes and process control 2. definitions of a process 3....

47
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model 5. Process Creation, what does it mean? 6. Process Termination’s meaning 7. A Five State Model of Process Control 8. Queuing Models of Systems having I/O 9. Swapping (Suspending) Processes 10. CPU with I/O and Suspended State

Upload: darlene-booth

Post on 05-Jan-2016

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Processes and Process ControlProcesses and Process Control

1. Processes and Process Control2. Definitions of a Process3. Systems state vs. Process State4. A 2 State Process Model5. Process Creation, what does it mean?6. Process Termination’s meaning7. A Five State Model of Process Control8. Queuing Models of Systems having I/O9. Swapping (Suspending) Processes10. CPU with I/O and Suspended State

1. Processes and Process Control2. Definitions of a Process3. Systems state vs. Process State4. A 2 State Process Model5. Process Creation, what does it mean?6. Process Termination’s meaning7. A Five State Model of Process Control8. Queuing Models of Systems having I/O9. Swapping (Suspending) Processes10. CPU with I/O and Suspended State

Page 2: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

11. Operations on Processes12. O/S Support for Processes13. O/S Global Process Structures14. Memory Tables15. I/O Tables16. File Tables17. Process Tables18. Process Image19. Process Control Blocks20. Process Memory Management21. O/S Use of PCBs22. O/S Kernel Services

11. Operations on Processes12. O/S Support for Processes13. O/S Global Process Structures14. Memory Tables15. I/O Tables16. File Tables17. Process Tables18. Process Image19. Process Control Blocks20. Process Memory Management21. O/S Use of PCBs22. O/S Kernel Services

Page 3: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

23. Process Switching24. Running the O/S25. Processing Threads26. Thread Management in Windows NT27. Examples - MVS28. MVS List Structures29. Examples - Unix30. Examples - Windows NT

23. Process Switching24. Running the O/S25. Processing Threads26. Thread Management in Windows NT27. Examples - MVS28. MVS List Structures29. Examples - Unix30. Examples - Windows NT

Page 4: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Definitions of A ProcessDefinitions of A Process

1. A program in execution2. An asynchronous activity3. the ``animated spirit'' of a procedure4. the ``locus of control'' of a program in execution5. that which is manifest by the existence of a process control block in the O/S6. that entity which is assigned to processors7. the ``dispatchable'' unit

1. A program in execution2. An asynchronous activity3. the ``animated spirit'' of a procedure4. the ``locus of control'' of a program in execution5. that which is manifest by the existence of a process control block in the O/S6. that entity which is assigned to processors7. the ``dispatchable'' unit

Page 5: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Systems state vs. Process StateSystems state vs. Process State

1. Some processes are resident in memory.

2. The kernel is always resident.

3. One process runs at a time.

1. Some processes are resident in memory.

2. The kernel is always resident.

3. One process runs at a time.

Page 6: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

A 2 State Process ModelA 2 State Process Model

CPU is the only resource for many jobs.

1. Enter --- Process Creation

2. Dispatch --- Scheduling/Queuing Discipline

3. Pause --- Give other jobs a chance

4. Exit --- Process Termination

CPU is the only resource for many jobs.

1. Enter --- Process Creation

2. Dispatch --- Scheduling/Queuing Discipline

3. Pause --- Give other jobs a chance

4. Exit --- Process Termination

Page 7: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 2. State Diagram of CPU only SystemFigure 2. State Diagram of CPU only System

Page 8: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Creation, what does it mean?Process Creation, what does it mean?

Some reasons for process creation include:

1. A new batch job2. Interactive O/S login3. O/S created4. Spawned by an existing process

The frequency of process creation

reflects the expense of creation.

Some reasons for process creation include:

1. A new batch job2. Interactive O/S login3. O/S created4. Spawned by an existing process

The frequency of process creation

reflects the expense of creation.

Page 9: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Termination's meaningProcess Termination's meaning

Some reasons for process termination include:

1. Normal Completion

2. Excessive Resource Usea) CPU Time Outb) Insufficient Memoryc) File system full error

Some reasons for process termination include:

1. Normal Completion

2. Excessive Resource Usea) CPU Time Outb) Insufficient Memoryc) File system full error

Page 10: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

3. Security Violations/Programmer Errorsa) Illegal Addressb) Illegal Instructionc) Privileged Instructiond) Data Misuse (type error/

initialization error)4. Systems Control

a) Parent Job Terminatedb) Terminated by Parentc) Operator or O/S intervention

3. Security Violations/Programmer Errorsa) Illegal Addressb) Illegal Instructionc) Privileged Instructiond) Data Misuse (type error/

initialization error)4. Systems Control

a) Parent Job Terminatedb) Terminated by Parentc) Operator or O/S intervention

Process Termination's meaning (continued)

Process Termination's meaning (continued)

Page 11: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Termination's meaning (continued)

Process Termination's meaning (continued)

The frequency of process creation

reflects the expense of creation.

The frequency of process creation

reflects the expense of creation.

Page 12: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

A Five State Model of Process ControlA Five State Model of Process Control

Blocking - When a process waits on a non-CPU service (typically I/O).

Real systems have I/O, so a more realistic model is:

Blocking - When a process waits on a non-CPU service (typically I/O).

Real systems have I/O, so a more realistic model is:

Figure 3

Page 13: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Queuing Models of Systems having I/OQueuing Models of Systems having I/O

An architecture with I/O and CPU is:

Figure 4

An architecture with I/O and CPU is:

Figure 4

Page 14: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Swapping (Suspending) ProcessesSwapping (Suspending) Processes

Suspending a Process - When the O/S saves the state of a non-running program from main memory to auxiliary memory.

Activation - When the O/S reloads a suspended process into main memory from auxiliary memory.

Suspending a Process - When the O/S saves the state of a non-running program from main memory to auxiliary memory.

Activation - When the O/S reloads a suspended process into main memory from auxiliary memory.

Page 15: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Some reasons for swapping out processes from memory

1. System malfunction - Save state and resume after fix

2. User suspicious about partial results- Debugging/ check-pointing

3. Correct short term load (or memory requirement) fluctuations

4. Fairness (one big process prevents others from running)

Some reasons for swapping out processes from memory

1. System malfunction - Save state and resume after fix

2. User suspicious about partial results- Debugging/ check-pointing

3. Correct short term load (or memory requirement) fluctuations

4. Fairness (one big process prevents others from running)

Swapping (Suspending) Processes (continued)

Swapping (Suspending) Processes (continued)

Page 16: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

CPU with I/O and Suspended StateCPU with I/O and Suspended State

We can either treat a suspension as independent from blocking, or as mutually exclusive.

We can either treat a suspension as independent from blocking, or as mutually exclusive.

Page 17: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 5: O/S supporting Blocking and Suspension

Figure 5: O/S supporting Blocking and Suspension

Page 18: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Operations on ProcessesOperations on Processes

Some operations on processes:1. Create a process2. Destroy (terminate) a process3. Block a process4. Suspend a process5. Resume (activate) a process6. Change a process's priority7. Wake up a process8. Wake up a process (put it into the ready state)9. Enable a process to communicate with another process (interprocess communication)

Some operations on processes:1. Create a process2. Destroy (terminate) a process3. Block a process4. Suspend a process5. Resume (activate) a process6. Change a process's priority7. Wake up a process8. Wake up a process (put it into the ready state)9. Enable a process to communicate with another process (interprocess communication)

Page 19: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

O/S support for ProcessesO/S support for Processes

The O/S in its role as resource manager and as run time interface controls resource access by mapping processes to resources.

The O/S in its role as resource manager and as run time interface controls resource access by mapping processes to resources.

Page 20: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 6: Process and ResourcesFigure 6: Process and Resources

Page 21: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

O/S Global Process Structures O/S Global Process Structures

The big picture for process management looks like:The big picture for process management looks like:

Figure 7: Processes and Resources

Figure 7: Processes and Resources

Page 22: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Memory TablesMemory Tables

Memory tables record the following information:1. The allocation of main and auxiliary memory to processes2. Memory protection (O/S vs. users, users from each other, read only vs. write instructions vs. data)3. Control information for the virtual memory manager

Memory tables record the following information:1. The allocation of main and auxiliary memory to processes2. Memory protection (O/S vs. users, users from each other, read only vs. write instructions vs. data)3. Control information for the virtual memory manager

Page 23: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

I/O Tables:Manage hardware control (and perhaps higher level control) of channels and peripherals in the system.

File Tables:Provide security, access control, and naming support for persistent objects.

Process Tables:Manages each individual process's data structures, stores security per-missions, and process state info.

I/O Tables:Manage hardware control (and perhaps higher level control) of channels and peripherals in the system.

File Tables:Provide security, access control, and naming support for persistent objects.

Process Tables:Manages each individual process's data structures, stores security per-missions, and process state info.

Page 24: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process ImageProcess Image

Process Image --- The state information (attributes) of the process (data/stack/instructions, I/O state). Process images typically contain:

1. User Data2. User Program (Instructions)3. System Stack

4. Process Control Block

Process Image --- The state information (attributes) of the process (data/stack/instructions, I/O state). Process images typically contain:

1. User Data2. User Program (Instructions)3. System Stack

4. Process Control Block

Page 25: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Control BlocksProcess Control Blocks

Process Control Blocks (PCBs)--- The data structures the O/S allocates for managing each process, containing:

1. Process identifiers --- process id, parent id, user id.2. Process State Info --- User Visible Registers, Control Registers (and PC), and stack pointer.

Process Control Blocks (PCBs)--- The data structures the O/S allocates for managing each process, containing:

1. Process identifiers --- process id, parent id, user id.2. Process State Info --- User Visible Registers, Control Registers (and PC), and stack pointer.

Page 26: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Control Blocks (continued)Process Control Blocks (continued)

3. Process Control Info --- Scheduling and State info, System Data Structures, Inter-process Communications, Process privileges, Memory Management, Resource Ownership and Utilization.

3. Process Control Info --- Scheduling and State info, System Data Structures, Inter-process Communications, Process privileges, Memory Management, Resource Ownership and Utilization.

Page 27: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Memory ManagementProcess Memory Management

Each process image is allocated its own virtual memory.Each process image is allocated its own virtual memory.

Figure 8: Process Memory Management

Figure 8: Process Memory Management

Page 28: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

O/S Use of PCBsO/S Use of PCBs

The system accesses processes via their PCBs for state transitions and scheduling as per state diagram and queuing models.

Process Lists --- Correspond to queues and service structures in queuing model.

The system accesses processes via their PCBs for state transitions and scheduling as per state diagram and queuing models.

Process Lists --- Correspond to queues and service structures in queuing model.

Page 29: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model
Page 30: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

O/S Kernel ServicesO/S Kernel Services

An O/S kernel provides privileged access to system resources, running in systems mode, control mode, or kernel mode.

Typical Kernel services include:

1. Process Management --- Process Creation, Process Termination, Process Switching Process Synchronization, Inter-process Communication.

An O/S kernel provides privileged access to system resources, running in systems mode, control mode, or kernel mode.

Typical Kernel services include:

1. Process Management --- Process Creation, Process Termination, Process Switching Process Synchronization, Inter-process Communication.

Page 31: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

2. Memory Management --- Allocation of address space to processes, Swapping, virtual memory management.

3. I/O Management --- Buffer management, device and channel allocation to processes

4. Systems Support --- Interrupt handling, Accounting, Monitoring.

2. Memory Management --- Allocation of address space to processes, Swapping, virtual memory management.

3. I/O Management --- Buffer management, device and channel allocation to processes

4. Systems Support --- Interrupt handling, Accounting, Monitoring.

O/S Kernel Services (continued)O/S Kernel Services (continued)

Page 32: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process SwitchingProcess Switching

Process switching is the O/S transferring control from one process to another. Issues include:

1. When to switch? Preemption vs. Non Preemption

Process switching is the O/S transferring control from one process to another. Issues include:

1. When to switch? Preemption vs. Non Preemption

Page 33: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Process Switching (continued)Process Switching (continued)

2. Context Switching --- done as follows:

a) Preserve the running process's

state in the PCB, if swapping

save image.

b) Load process image's PCB into

system registers and memory

restore the program counter.

2. Context Switching --- done as follows:

a) Preserve the running process's

state in the PCB, if swapping

save image.

b) Load process image's PCB into

system registers and memory

restore the program counter.

Page 34: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Running the O/SRunning the O/S

The following are typical of O/S run time support structures:

1. Non-process O/S --- A more primitive structure (MS-DOS, CP/M)2. Single separate Kernel Process --- A more monolithic approach, has the efficiency advantage of fewer context switches, but less flexible (macrokernel?). (Unix/Linux, Mac OS, VM, MVS).

The following are typical of O/S run time support structures:

1. Non-process O/S --- A more primitive structure (MS-DOS, CP/M)2. Single separate Kernel Process --- A more monolithic approach, has the efficiency advantage of fewer context switches, but less flexible (macrokernel?). (Unix/Linux, Mac OS, VM, MVS).

Page 35: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Running the O/S (continued)Running the O/S (continued)

3. System services via Kernel and User

processes --- A more flexible approach

(microkernel?). (Windows NT, OS/2,

MACH, GNU HURD, Amiga DOS).

3. System services via Kernel and User

processes --- A more flexible approach

(microkernel?). (Windows NT, OS/2,

MACH, GNU HURD, Amiga DOS).

Page 36: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Processes and ThreadsProcesses and Threads

Some people consider threads as a special form of process.1. Processes control a unit of resource ownership.2. A process is typically the unit of dispatching.3. Threads share process context,4. Threads are asynchronous,5. Threads have less context than processes.

Some people consider threads as a special form of process.1. Processes control a unit of resource ownership.2. A process is typically the unit of dispatching.3. Threads share process context,4. Threads are asynchronous,5. Threads have less context than processes.

Page 37: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Processes and ThreadsProcesses and Threads

6. Threads can be created/terminated at

a lower cost.

7. Threads cooperate to do a process in parallel with (relatively) fine

granularity of parallelism

Threads are suited to shared memory SMP machines.

6. Threads can be created/terminated at

a lower cost.

7. Threads cooperate to do a process in parallel with (relatively) fine

granularity of parallelism

Threads are suited to shared memory SMP machines.

Page 38: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Thread Management in Windows NTThread Management in Windows NT

Threads typically cooperate to do the same work as a traditional process. Often the system services are done in user space in a micro-kernel system (to make them run time configurable/flexible with an efficiency penalty).

Threads typically cooperate to do the same work as a traditional process. Often the system services are done in user space in a micro-kernel system (to make them run time configurable/flexible with an efficiency penalty).

Page 39: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 10: Cooperation in a Typical Thread System-NTFigure 10: Cooperation in a Typical Thread System-NT

Page 40: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Examples --- MVSExamples --- MVS

MVS has 3 task (process) states: Ready, Active, Waiting. Entire task may be swapped to auxiliary storage.

Consider a task composed of:1. a main program,2. a customer inquiry module,3. an order entry module and4. a production tracking module

MVS has 3 task (process) states: Ready, Active, Waiting. Entire task may be swapped to auxiliary storage.

Consider a task composed of:1. a main program,2. a customer inquiry module,3. an order entry module and4. a production tracking module

Page 41: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 11: MVS Address Space ExampleFigure 11: MVS Address Space Example

Page 42: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

MVS List StructuresMVS List Structures

MVS tracks system resources used and tasks using list structures.MVS tracks system resources used and tasks using list structures.

Page 43: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 12: MVS List Structures Example

Figure 12: MVS List Structures Example

Page 44: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Examples --- UnixExamples --- Unix

Unix has a macro-kernel, and processes (some versions now have thread support).Unix has a macro-kernel, and processes (some versions now have thread support).

Page 45: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 13: Unix Process StatesFigure 13: Unix Process States

Page 46: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Examples - Windows NTExamples - Windows NT

Windows NT is multithreaded, and allocates handles for managing processes and resources.

The access token identifies the user, and their security permissions.

Windows NT is multithreaded, and allocates handles for managing processes and resources.

The access token identifies the user, and their security permissions.

Page 47: Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model

Figure 14: An NT Process and Its ResourcesFigure 14: An NT Process and Its Resources