You are on page 1of 15

PROCESS

Process Model, Creation, States, Termination and Implementation


PROCESS: Central Concept

 Abstraction of running program


 Modern computers do several tasks at same time

2. Checks in Multiple Disks


1. Request cache
Comes for
4. If not, Disk
Webpage
Cach Request is started
e and waits for
response
3. If present sends
Response to User NOTE:
response
Huge Speed difference b/w CPU and Disk

Web Server
Pseudoparallelism: Multiprogramming

Printing Backup
File Photos Pseudoparallelism:
One CPU switches from process to process quickly,
running each for tens or hundreds of milliseconds.
Web Playing
Surfing Music

Incoming
Antivirus
Email

PC
booted
Process Model
 All runnable software are organized into sequential processes
 Process (An instance of executing program including current values of program counter, registers
and variables)

Computer
Multiprogrammin
g four programs
in Memory
‫مثال‬

‫‪ ‬مثال یو نفر دي چه یو کیک پخوي نو دی د کیک ریسفي او اشپزخانه لري چه پکښی ټول سامان د کیک پخولو‬
‫لکه شیدی هګی بوره موجود دي چه کیک ریسفی د یو پروګرام مثال لري چه د کیک پخولو یوه طریقه الګوریتم‬
‫پکښی ذکرشوی او نفر د پروسیسر مثال لري چه ترسره کوونکی یا پخوونکي د ریسفي دي او مواد د کیک د ډیټا‬
‫مثال لري او د ریسفي ویل‪ ،‬مواد سره ګډول عبارت د پروسیس څخه دي اوس فرضآ د دهغه نفر بل کوچنی زوی‬
‫په ژړه راځغلي او نعری وهي چه غالبوزي وخوړلم نو نفر هغه ریسفي پر هغه ځاي پریږدي او طبی مواد راخلي‬
‫د زوي د زخم کار ورکوي چه دلته یو پروسیس یا کار پریږدی او بل شروع کوي چه اهمیت یی زیات وي چه د‬
‫زوي د زخم کار خالص سو بیرته خپل اول کار شروع او خالصوي‬

‫اساسی مفاهیم‪:‬‬
‫پروسیس یو جریان دی چه انفوټ‪ ،‬اوټفوټ اویو حالت لري‪.‬‬
‫یو پروسیسر کوالي سو په مختلفو ‪ scheduling algorithms‬سره مختلف پروسیسو باندي په مختلف اندازو سره کار وکړي‬
‫او یو پروګرام هغه دي چه په ډیسک کی ثبتیږي او کوم خاص څه سرته نه رسوي‬
‫يو پروګرام چه دوه ځلي روان سی نو دوه پروسیس ځنی جوړیزي لکه مایکروسافټ ورډ‬
PROCESS CREATION

 OS needs some way to create processes


 Simple System V/S General Purpose System
 Four Events That Cause Process To Be Created
1. System Initialization
 System booted numerous process created some foreground and other background ( Daemons ) like Incoming email

2. Execution of process-creation system call by a running process


 Large data fetched over network one process to put in shared buffer while other to process it

3. User request to create a new process


 In interactive system clicking an icon or typing command

4. Initiation of a batch job


 Inventory Management at the end of day receives batch of jobs from different chain of stores
Process Creation

New PS created by existing process execute Process creation system call


Running User Process – System Process invoked from Keyboard or Mouse – Batch Manager
Process
Process executes System Call  System Call tells OS to create a new process indicating
which program to run

Fork System Call:- creates exact clone of existing process after fork called both parent and
child have same memory image, same environment strings and same open files usually child
process then executes EXECVE system call or similar system to change memory image and
run new program
sort command to shell  shell forks off child process
i.e.
and child executes sort(reason to manipulate its file descriptor
after FORK before EXEVE to accomplish Standard IN,OUT, ERR)
Window CreateProcess Call

 In Windows Win32 Function Call ( CREATEPROCESS ) : Handles both process creation and loading
correct program into new process
 CREATEPROCESS has around 10 Parameters
 Program to be executed
 Various security attributes
 Bit for open files info
 Priority information
 Specification for window to be created for process
 Pointer to a structure of information to be returned to caller
 Win32 has about 100 functions like CP to manage synchronize Process
AFTER PROCESS CREATION

 After Process creation both Parent and child have their distinct Address Space
no writable memory shared
 Some Unix Implementation share program text between but can’t be modified
and child may share parent’s memory but memory is shared copy-on-write
(that chuck of memory is copied first to private area then edited) No writable
memory is shared
 Windows Parent and child Address Space are different from Start
PROCES TERMINATION

 All created processes run and does the job the required eventually terminates
due to one of following conditions:
1. Normal Exit ( Voluntary )
 Such X button in Graphical window or Exit System Call

2. Error Exit ( Voluntary )


 Program bug, Illegal instruction, Referencing nonexistent memory division by zero

3. Fatal Error ( Non Voluntary )


 Non existent file execution or try again pop ups

4. Killed by another Process ( Non Voluntary)


 Kill system Call or TerminateProcess Call but must have necessary authorization
PROCESS HIERARCHIES

 When a process creates another process, parent and child process are associated to each other
 In Unix a process and all its children or descendants together form a process group when a user
sends a signal from keyboard the signal is delivered to all members of associated group
 Such as when Unix is booted “init” process is started from boot image and starts running and read how
many terminals are there and accordingly forks off new process per terminal and login process is started
as that accepted then it starts shell script to accept commands
 In Contrast windows has no Process Hierarchy rather it has special token called Handle which has
control of Child process but it can be passed to another Process thus invalidating Process
Hierarchy
Process States

There are three states of a Process


1. Running State
Interrupt handling and
 Using CPU at that instant details of actually
2. Ready State starting and stopping
 Runnable, Temporarily stopped to let another process run
processes is scheduler

3. Blocked State
 Unable to run until some external event happens

NOTE:-

There are four transitions among


three state 1 can’t continue 2 & 3
Decided by Scheduler 4 when
waiting events occurs
IMPLEMENTATION OF PROCESSES

 To implement process model O.S. maintains Process Table( Array of


Structures ) each entry is Process Control Block, important info about
Process state, Program Counter, Stack Pointer, Memory Allocation

Each I/O Class has an associated Location


called Interrupt Vector ( Has Address of
Interrupt service procedure )
Context Switching

1. All Interrupts start by


saving registers
2. Then info on stack is
removed and pointer
set to temporary Stack
( Assembly Language )
3. When job done possibly
4. making some process
Disk Interrupt ready, then scheduler
User P 3 running
Happened Interupp called to run next.
PC, PSW, Rs
t
hardwar P.C. , Regs, PSW
e And jumps to
INTERRUPT SERVICE
PROCEDURE
Modelling Multiprogramming

 Multiprogramming improves CPU utilization


 If averages process computes 20% of time being in memory then 5 processes
at a time in memory would utilize completely
 CPU Utilization = 1 – pn where p is time waiting for I/O and n number of processes
in memory
 8GB RAM 2GB OS 3X 2GB USER
with 80% I/O time
 CPU U = 1 – 0.83 ~ 49%

You might also like