Sie sind auf Seite 1von 25

Operating Systems

AICT004-4-2 and Version VC1

Process Control Management


Topic & Structure of the lesson

• Process and Thread Concepts

• Process States

• Process Scheduling

AICT004-4-2-OS Operating Systems Process Control Management Slide 2 of 25


Learning Outcomes

• At the end of this lecture YOU should be able to:

- define the term process

- identify process states

- draw and explain process states using process


state diagrams

- describe how process scheduling works

AICT004-4-2-OS Operating Systems Process Control Management Slide 3 of 25


Key Terms you must be able to use

If you have mastered this topic, you should be able to use


the following terms correctly in your assignments and
exams:

• process
• threads
• process control block
• process states
• concurrent processes

AICT004-4-2-OS Operating Systems Process Control Management Slide 4 of 25


Process

• What is a process?

- it is a program in execution which progresses in a


sequential manner

- it is a unit of work with a unique process


identification

- requires resources like memory, CPU time and


files to complete its task

- resources are allocated when a process is created


or while in execution
AICT004-4-2-OS Operating Systems Process Control Management Slide 5 of 25
Process (cont.)

• the operating system creates and deletes user and


system processes

• a process is active while a program is passive

• the operating system keeps track of processes


using a process table

AICT004-4-2-OS Operating Systems Process Control Management Slide 6 of 25


Process State Diagram

new terminated
admitted exit

Interrupt / time out

ready
running

scheduler dispatch
I/O or event I/O or event wait
completion
blocked

AICT004-4-2-OS Operating Systems Process Control Management Slide 7 of 25


Process States

• as a program executes, it changes states

• New
- a process has just been created

• Reasons for process creation


- new batch job
- interactive logon

• a NEW process now becomes READY

• Ready
- the process is waiting to be assigned to a processor
AICT004-4-2-OS Operating Systems Process Control Management Slide 8 of 25
Process States (cont.)

• READY - RUNNING
- instructions are being executed
- a process is using the CPU
- the number of running processes will depend on the
number of processors the computer has

• A running process now can become BLOCKED, READY


or TERMINATED

• A RUNNING process becomes BLOCKED when :


- the process itself cannot execute because it is waiting
for an I/O operation to complete
- the process is waiting for some external event to happen
AICT004-4-2-OS Operating Systems Process Control Management Slide 9 of 25
Process States (cont.)

• From BLOCKED the process then becomes READY when:


- an event which the process was waiting for occurs

• A RUNNING process becomes READY when:


- a process has reached its maximum allowable time for
uninterrupted execution

AICT004-4-2-OS Operating Systems Process Control Management Slide 10 of 25


Process States (cont.)

• From RUNNING the process then TERMINATES when:


- a process has completed
- a process has been aborted

• Reasons for process termination


- normal completion
- invalid instruction
- memory unavailable

• Control is then returned to the operating system

AICT004-4-2-OS Operating Systems Process Control Management Slide 11 of 25


Quick Review Questions

• For each of the following transitions between process


states indicate whether the transition is possible or not
possible?

ready running
ready new
blocked ready

• On a system with n number of CPU’s what is the


minimum number of processes that can be in the ready,
running and blocked state?

AICT004-4-2-OS Operating Systems Process Control Management Slide 12 of 25


Process Control Block (PCB)

• Each process is represented in the operating system as


a process control block (PCB)

• a PCB:

- keeps track of each process

- contains information associated with a specific


process

- serves as a repository of any information that may


vary from process to process

AICT004-4-2-OS Operating Systems Process Control Management Slide 13 of 25


Process Control Block Diagram

Pointer to parent process


Pointer area to child process
Process state
Program counter
Register save area
Memory limits
Priority information
Accounting information
Pointer to files and other
I/O resources
AICT004-4-2-OS Operating Systems Process Control Management Slide 14 of 25
Process Control Block

• Process state – the process states; ready, running,


blocked, terminated

• Program counter – indicates the location for the next


instruction

• Priority information - CPU scheduling information

• Accounting information – statistics on CPU time, job and


process numbers

• I/O status – list of I/O devices which are allocated to


processes
AICT004-4-2-OS Operating Systems Process Control Management Slide 15 of 25
Process Scheduling

• As processes enter the system, they are put on


the job queue

• A new process is put on the ready queue

• The process waits until it is selected for execution


or dispatched and given CPU resources

• Once CPU is allocated the process then runs:

- the process could issue an I/O request and be


placed on a device queue or I/O queue
- the process could create a new sub-process
- the process could be forcibly removed
AICT004-4-2-OS Operating Systems Process Control Management Slide 16 of 25
Process Scheduling Diagram
ready queue CPU

I/O I/O queue I/O request

time slice
expired

child
fork a child
executes

interrupt wait for an


occurs interrupt

AICT004-4-2-OS Operating Systems Process Control Management Slide 17 of 25


Types of processes

• Concurrent processes can be independent or


cooperating processes:

- independent processes are processes that do not


need to interact with other processes

- cooperating processes are processes that work with


each other, can affect or be affected by another
process

AICT004-4-2-OS Operating Systems Process Control Management Slide 18 of 25


Types of processes (cont.)

• Why should an operating system allow for


cooperating processes?

- to allow information sharing


- to allow access to resources
- to increase computation speed

AICT004-4-2-OS Operating Systems Process Control Management Slide 19 of 25


Threads

•a mini lightweight process that can execute independently


of other parts of the process

• two types of threads:


- user processes
- system processes

• creation of a new process (child) from the older one


(parent) is called spawning or forking

AICT004-4-2-OS Operating Systems Process Control Management Slide 20 of 25


Quick Review Questions

• What is a process control block?

AICT004-4-2-OS Operating Systems Process Control Management Slide 21 of 25


Follow Up Assignment

• Draw and explain the process state diagram

• What does a CPU do when there are no processes to


run

AICT004-4-2-OS Operating Systems Process Control Management Slide 22 of 25


Summary of Main Teaching Points

• A process is a unit of work in execution which


requires resources.

• The state of a process changes as it executes.

• A process control block represents a process in the


operating system.

• Processes can execute concurrently or


independently from each other.

• A thread is an independent basic unit of CPU


utilization.
AICT004-4-2-OS Operating Systems Process Control Management Slide 23 of 25
Question and Answer Session

Q&A

AICT004-4-2-OS Operating Systems Process Control Management Slide 24 of 25


Next Session

CPU Scheduling

AICT004-4-2-OS Operating Systems Process Control Management Slide 25 of 25

Das könnte Ihnen auch gefallen