2a Process Concepts
-
Upload
faizah-rozali -
Category
Documents
-
view
222 -
download
0
Transcript of 2a Process Concepts
-
8/2/2019 2a Process Concepts
1/31
Operating Systems
Operating Systems-
Process Concept in Operating Systems
hapter2
Prepared by:Dr. Subariah Ibrahim, Maznah Kamat, Noh Abd Samad, Muhalim Mohamed Amin
1
-
8/2/2019 2a Process Concepts
2/31
Operating SystemsOperating Systems
Process Concepts
Thread Conce t
Process Scheduling
hapter2
2
-
8/2/2019 2a Process Concepts
3/31
Operating Systems
Chapter 2
PROCESS CONCEPTS
Definition
Process States
hapter2
Process Creation & Termination
3
-
8/2/2019 2a Process Concepts
4/31
Operating SystemsOperating Systems
Definition A Process is an instance of program execution.
Two processes may come from the samero ram, however their executions are different.
Therefore each one is a different process. Example: If two users are running a word
processor, two processes will be created.
A program is a passive entity whereby it
hapter2
compr ses o program co ng, w c s a s a centity. Therefore, a program itself is not a
.
4
-
8/2/2019 2a Process Concepts
5/31
Operating SystemsOperating Systems
Components of a Process
Context of a program execution:
-
registers, program counter Other information needed by the operating system
eg. Process state, scheduling information.
Program Data
hapter2 tac stores temporary ata su rout ne
parameters, local variables, return address)
5
-
8/2/2019 2a Process Concepts
6/31
Operating SystemsOperating Systems
Process States
Process states depict the current activity of a.
When a process is executed, the process will.
changes states after an event occurs.
causes a process to change states
hapter2
Two-State Model
ve- a e o e
6
-
8/2/2019 2a Process Concepts
7/31
Operating SystemsOperating Systems
Process with Two-State Model
A process can be in one of the following states:
-
- Not-running
Enter ExitRunninNot
hapter2
unn ng
7
-
8/2/2019 2a Process Concepts
8/31
Operating SystemsOperating Systems
Two-State Model : Queue Diagram
EnterQueue
Dispatch Exit
CPU
Pause
hapter2
8
-
8/2/2019 2a Process Concepts
9/31
Operating SystemsOperating Systems
Five-State Model
New The process is being created
Running Instructions are being executed
Read The rocess is waitin to be
assigned to a CPUWaiting / Blocked The process is waiting for some
event to occur, eg: I/O completion
Exit The process has finished execution
hapter2
Note: different operating system assign different names for the states.9
-
8/2/2019 2a Process Concepts
10/31
Operating SystemsOperating Systems
Five-State Model:
AdmitDispatch
ew ea y unn ngInterru t terminate
event wait
event
occurs
hapter2
WaitingExit
10
-
8/2/2019 2a Process Concepts
11/31
Operating Systems
Five-State Model:
hapter2
11
-
8/2/2019 2a Process Concepts
12/31
Operating SystemsOperating Systems
Process Description
OS controls all the events that occur in a computer
system. ere ore some ata structure s nee e to eep
track of this information
P1 P3P2Virtual
emory
Computer
hapter2
CPU I/O I/O I/O Memory
Resources
AllocatedRequest
12
-
8/2/2019 2a Process Concepts
13/31
Operating SystemsOperating Systems
Information Table (cont)
OS needs to keep track on the status of each
computer system.
Done by keeping the information in tables asfollows:
Memory Table
I/O Table
hapter2
ProcessTable
13
-
8/2/2019 2a Process Concepts
14/31
Operating SystemsOperating Systems
Information Table (cont)
Memory Tables Process
Memory
Devices I/O Tables
Image
for
Process 1
FilesProcesses File Tables
Process Tables
Process 1
Process
Image
hapter2
Process n
.
.or
Process n
14
-
8/2/2019 2a Process Concepts
15/31
Operating SystemsOperating Systems
Process Control Block (PCB) (cont)
Each process has a PCB
Contents of PCB:
a rocess en ca on
Numeric identifiers that may be stored with the processcontrol block include:
Identifier of this process
Identifier of the process that created this process (parent
hapter2
User identifier
15
-
8/2/2019 2a Process Concepts
16/31
Operating SystemsOperating Systems
(b) Processor State Information
General purpose registers
Control and status registers (Program counter; PSW-,
Process state, scheduling information such as priority,amount of time executed the last time
Memory management information eg. Pointers to page table
Resource ownership and utilization eg. opened files
hapter2 Data Structuring eg. Parent-child relationship, link to other
processes in a queue
16
-
8/2/2019 2a Process Concepts
17/31
Operating SystemsOperating Systems
Operations on Process
OS needs to provide a mechanism for:(a) Process Creation
A process can create another process
parent process The process being created is known as a child
process
Every new process can create another process
hapter2
(b) Process Termination
terminates17
-
8/2/2019 2a Process Concepts
18/31
Operating SystemsOperating Systems
(a) Process Creation
Operations involved:
Keep the process information in a process table
Allocate space for the process Reasons for Creation:
Submission of a new batch job
A user logs on to a computer system
hapter2 Created by OS to provide a service such as
printing
Spawned by existing process
18
-
8/2/2019 2a Process Concepts
19/31
Operating Systems
Example: UNIX Process Hierarchy
hapter2
19
-
8/2/2019 2a Process Concepts
20/31
Operating SystemsOperating Systems
Example: UNIX Process Creation
the processes memory space with a new
program.
hapter2
20
-
8/2/2019 2a Process Concepts
21/31
Operating SystemsOperating Systems
(b) Process Termination
Reasons for Termination :
Program has completed User logs off
Quit an application
Error and fault conditions: Memory unavailable
ro ec on error
Arithmetic error
hapter2
Operations in Process Termination:
De-allocate resources21
-
8/2/2019 2a Process Concepts
22/31
Operating SystemsOperating Systems
Context Switchin 1/2
Changes in information when CPU is switchedfrom one process to another
Store the current process state for the processthat leaves CPU in its PCB.
hapter2
allocated CPU from its PCB.
22
-
8/2/2019 2a Process Concepts
23/31
Operating SystemsOperating Systems
Context Switchin 2/2
Time taken for context switching is considered asystem overhead.
The speed varies from machine to machine,de endin on the memor s eed, the number ofregisters that must be copied and the existence
of special instructions.
hapter2
T ical s eeds are a few milliseconds.
23
-
8/2/2019 2a Process Concepts
24/31
Operating Systems
Context Switching between 2 processes
hapter2
24
-
8/2/2019 2a Process Concepts
25/31
Operating SystemsOperating Systems
When to Switch a Process
Clock interrupt
Means process has executed for the maximum allowable timeslice
The value of timer is zero
Memory fault memory address is in virtual memory so it must be brought into
main memory
Trap
hapter2
may cause process to be moved to Exit state
Su ervisor call/s stem call
such as file open, print on printer25
-
8/2/2019 2a Process Concepts
26/31
Operating SystemsOperating Systems
Cooperating Processes (1/2)
Concurrent Processes can be:
Independent processes
canno a ec or e a ec e y e execu on oanother process.
Cooperating processes
can affect or be affected by the execution of
hapter2 another process.
26
-
8/2/2019 2a Process Concepts
27/31
Operating SystemsOperating Systems
Cooperating Processes (2/2)
Advantages of process cooperation:
Computation speedup
Convenience (e.g. editing, printing, compiling)
Concurrent execution requires
process communication and process
hapter2 synchronization
27
-
8/2/2019 2a Process Concepts
28/31
Operating Systems
Example:oncurrent
Execution ofrocesses(1/3)
hapter2
28
-
8/2/2019 2a Process Concepts
29/31
Operating Systems
Example:
Execution of
(2/3)
hapter2
29
-
8/2/2019 2a Process Concepts
30/31
Operating Systems
Example:
Execution of
(3/3)
100 = Starting address ofdispatch program.execution of dispatcherprocess;
1st & 3rd columns court
hapter2 instruction cycles;
2nd & 4th columns showsaddress of instruction being
30
.
-
8/2/2019 2a Process Concepts
31/31
Operating Systems
Example: Concurrent Execution of Processes(Process States)
hapter2
31