SlideShare a Scribd company logo
1 of 41
PROCESS CONCEPT
Operating Systems
CHAPTER # 3
Chapter 3 - Outline
 Process Concept
 Program vs Process
 Process Control Block
 Process Table
 Context Switch
 Process states
 Process states transitions
 Process life cycle
 Five state process model
 Unix process state transition diagram
Process Concept
 A process is basically a program in execution
 or that which a processor executes
 A process is unit of work in a system
 A process is an activity performed by a system
 It may be program’s data, program counter, pointer or register
used in a program
 A process uses resources like CPU, memory, files and I/O
devices
 Operating system processes execute system code and
user processes executes user code
Program vs Process
 A program is a passive entity
 A process is a dynamic entity represented by the
values stored in registers, memory, program
counters etc.
 A program does not compete for the computing
resources whereas a process does
 One program can have several processes
 Consider multiple users executing the same program
Process Concept
 Multiple parts
 The program code, also called text section
 Current activity including program counter, processor
registers
 Stack containing temporary data
 Function parameters, return addresses, local variables
 Data section containing global variables
 Heap containing memory dynamically allocated during run
time
Process Concept ()
 Process idea was first used in Multics
 All programming OS, such as Windows NT, or MVS
(multiple virtual storage) were built around the concept
of process
 Major requirements that the OS must meet can all be
expressed with reference to process
 OS must interleave the execution of a number of processes to
maximize processor use
 OS must allocate resources to process in confirming to a specify
policy
 e.g. certain functions or applications are of higher priority
 at the same time avoiding deadlock
 OS may support inter-process communication
Process Control Block (PCB)
 When a new user program is initiated
 OS creates a data structure, called Process Control Block (PCB), which
gives substance to the process and serves to control it
 Each process is represented by its own process control block
 PCB is a data block or record containing information associated with a
specified process
 Allows the OS to locate all key information about a process
 When the OS switches the attention of the CPU among various active
processes
 It uses the same area in PCB to hold the information
 That information used to restart process when the process next gets
CPU
 Process control block is also called task control block
Process Control Block (PCB)
 PCB contains following information about process
 Current state of the process
 Unique identification of process
 A pointer to process parent
 Pointer to process’s child processes
 The process’s priority
 Pointer to locate the process memory
 Pointer to allocate resources
 The register save area – CPU register
 The processor it is running on
 Accounting information
 I/O state information
Process Control Block (PCB)
Pointer Process state
Process number
Program counter
Registers
Memory limits
List of open files
.
.
.
Process Table
 OS maintains the process table with one entry per
process
 This entry contains information about process’s
 state
 its program counter
 stack pointer
 memory allocation
 the status of its open file
 its accounting and scheduling information
 its priority
The Shell
 It is a command interpreter
 It is a process which starts by typing a command at
prompt
 It provides an interface to the OS for the user
 A facility for online users rather than batch
 Command can be entered
 directly at an online terminal
 through shell program or script
 a text file having series of commands forms a script
 DOS shell is alternative as screen oriented interface
The Shell
 In Unix when any user login in, a shell is started up
 It starts up as soon as user types some thing at command
prompt, e.g. date
 The shell creates a child process and run the date program
 When child is running shell waits for its termination
 When child finishes, the shell types $ prompt again and
wait for next command
The Shell
Shell Process
Process executing
grep
File studentInfo
$ grep First studentInfo
First
Operations on Process ()
 A system managing processes may perform following operations
 Create a process
 Destroy a process
 Suspend a process
 Resume a process
 Block a process
 Wakeup a process
 Dispatch a process
 Change process’s priority
 Enable a process to communicate with other processes
 For long term suspension, process’s resources should be free
 Changing the priority of process normally involved modifying the
priority value in PCB
Process Creation & Termination
 A process may create other processes
 When a process creates a new process
 The creator process is called the parent process
 Created process is called the child process
 Act of creating a process is called spawning a
process
 A child process may share the resources of its parent
process
Process Creation & Termination
 A parent may wait for its child process to terminate
before resuming or may run concurrently with the
child process
 A child process may run the same program as that of
its parent or may run a separate program
 In DOS, parent and child process do not run in
parallel and parent process will suspend itself till
child has finished
Process Creation & Termination ()
 When a process is created the following operations are
performed
 Process naming (process id)
 Creates the process control block
 Insert it in process table
 Determine the process initial priority
 Allocate the process’s initial resources
 Allocate the address space to be used by the process
 When a process is destroyed following operations are
performed
 Its resources are returned to the system
 Its process control block is erased
 It is purged from any system list or table
Reasons for Process Creation
1. New batch job
 In a batch environment, a process is created in response to the
submission of a job
2. Interactive log on
 A user at a terminal logs on to the system
3. Created by OS to provide a service
 OS can create a process to perform a function on behalf of a user
program, without user having to wait, e.g. printing
4. Spawned by existing process
 A user program can create a number of processes
 Typically related processes need to communicate and cooperate
each other
 Achieving this cooperation is a difficult task for the programmer of OS
Reasons for Process Termination
 There must be some means for a process to indicate
its completion
 A batch job should include a halt instruction, which
generates an interrupts to alert the OS that a process has
completed
 For an interactive application, the action of the user will
indicate whether the process is completed
Reasons for Process Termination
Following are the possible reasons for process termination;
1. Normal termination
 The process executes an OS service call to indicate that it has
completed running
2. Time limit exceeds
 The process has run longer than the specified total time limit which
includes
 total time elapsed
 amount of time spent executing
 in case of interactive process, he amount of time since the user last
provided any input
3. Memory unavailable
 The process requires more memory than the system can provide
Reasons for Process Termination
4. Bounds violation
 The process tries to access the memory locations that is not allowed
to access
5. Protection error
 The process attempt to use a file that is not allowed to use or,
 It tries to use it in improper fashion, such as writing to a read only
file
6. Arithmetic error
 The process tries a prohibited computation such as division by zero
7. Time overrun
 The process has waited longer than specified maximum for a certain
events to occur
Reasons for Process Termination
8. I/O failure
 An error occur in input or output, such as
 inability to find a file
 failure to read a write after a specified maximum no of tries (when, e.g. a
defective area is encountered on a diskette) or
 invalid operation (such as reading from the line printer)
9. Invalid instruction
 The process attempts to execute a non-existent instruction (often a
result of branching into a data area and attempting to execute data)
10. Privileged instruction
 The process attempts to use an instruction reserved for the operating
system
Reasons for Process Termination ()
11. Data misuse
 A piece of data is of the wrong type or is not initialized
12. OS or operator intervention
 For some reason, the operator or the OS has terminated the process
(e.g. if a deadlock exists)
13. Parent termination
 When a parent terminates, the OS should be design to automatically
terminate all the offspring of that parent
14. Parent request
 A parent process typically has the authority to terminate any of its
offspring
Process States
 A process may have the following three states
 Running
 Instructions are being executed
 Waiting/Blocked
 The process is waiting for some event to occur (may be I/O completion)
 Ready
 The process is waiting to be assigned to processor
 At any instant a process is in one and only one of three states
 Process entering the system must go initially into the ready state
 Process can only enter the running state via the ready state
 Many OS are constructed using only these three states
 However, there is good justification for adding additional states to the model
Process States
Ready
Running
Blocked
I/O Completion
Process State Transitions
 Transition-1:
 Occurs when a process cannot continue may be due to I/O request
 Transition-2:
 Request when scheduler decides that the running process has run long
enough , and it’s the time to give CPU to other processes in ready state
 Transition-3:
 Occurs when all the other process have had their CPU time and its time for
the first process to run again
 Transition-4:
 Occurs when external event for which process was waiting happens. If no
other process is running at that time, transition-3 will be triggered and the
process will start execution
Process State Transitions
Ready
Running
Blocked
2 1
3
4
 The four transitions can be indicated as follows
 Block running  block
 Timerunout running  ready
 Dispatch ready  running
 Wakeup block  ready
Context Switch
 Context switching is the procedure of switching of process
from processor to memory and vice versa in a
multiprogramming environment
 When CPU switches to another process
 The system must save the state of the old process
 Load the saved state of the new process
 Context switch involves storing and loading the values of each
of the process’s control block, and process registers, such as;
 The program counter
 Index register
 General register
 Stack pointer etc
Context Switch
 Context switch is pure overhead
 The system does no useful work while switching
 Context switch time depends on hardware support e.g,
memory speed, the number of registers etc.
 Its range is from 1 to 100 microsecond
 This speed vary from system to system
Context Switch
Process Life Cycle
 As a process executes, it changes state
 new: The process is being created
 running: Instructions are being executed
 waiting: The process is waiting for some event to occur
 ready: The process is waiting to be assigned to a process
 terminated: The process has finished execution
Process Life Cycle
Process Life Cycle
 Assume that process is running with a Unix operating system with no user
process
 Various events in life of processes within a multiprogramming system are
given below;
 User using the shell command interpreter, types in a program name, say solvit
 The shell finds this program and program code will be loaded
 A system call will be used to generate a process corresponding to the
execution of the solvit program
 The OS creates process control block in the memory
 The process solvit will now begin to run – the process is said to be in running
state
 After a while, solvit needs to read some data from a disk file and issue an
appropriate system call
 The process is now said to be in the blocked state
Process Life Cycle
 In the mean time, another user wants to run a program called myprog
 A new process is created for myprog and since solvit is currently idle,
execution begins; myprog is now running
 The I/O delay which is blocking solvit now ends and solvit wants to
restart; solvit is now said to be in ready state
 The OS scheduler now decides that myprog has enough processor time
(Timeout) and moves it into the ready queue
 Solvit is restarted and enters the running state once more
 Switching between active processes, waiting for I/O transfer etc. will
continue for the life of the processes
 Eventually, solvit completes its tasks and terminates; it leaves the running
state and disappears from the system
 Similarly myprog terminates
Five State Process Model
Blocked
Suspended
Admit
I/O Completion
Suspended
I/O Request
Release
Time-out
Dispatch
Suspended
Resume
Admit
Resume Suspended
Running
Blocked
Ready
Ready
Suspended
Five State Process Model
 There are two queues; a ready queue and a blocked queue
 OS chooses a process the ready queue to run
 In the absence of any priority scheme, this can be a simple FIFO
 A running process is removed from execution, it is either
 Terminated
 Time quantum is over
 Performed I/O
 After I/O completion processes in blocked queue are moved to ready queue
 When an event occurs, the OS must scan the entire blocked queue
 In a large OS, there could be hundreds or even thousands of processes in that
queue
 It would be more efficient to have a number of queues, one for each event
 When an event occurs, the entire list of processes in the appropriate queue can
be moved to the ready state
Five State Process Model
 Consider a system that does not employ virtual memory
 Each process to be executed must be loaded fully into memory
 In multiple blocked queuing model, all the processes in all the queues must be resident
in memory
 Memory holds multiple processes
 Solutions
 Expand the memory
 it has own flaw
 Cost associated with expansion
 Swapping
 Moving part or all of a process (blocked) from memory to disk (suspended queue)
 The space that is freed up in memory can be then be used to bring another
process
 When a process is suspended, it becomes dormant and merely waits until it is
resumed by the system or user
Five State Process Model
 A process can be suspended for the following reasons;
 Process being swapped put of the memory by the memory
management system in order to free memory for higher priority
processes
 A user may wish to suspend execution of a program for purpose of
debugging a program
 Process investigates previous effects of the process
 Processes designed to run periodically to monitor system usage
 The OS may suspend a background or utility process or a process that
is suspected of causing a problem
 The process can be suspended while in running, ready or blocked state
Unix Process State Transition
2
8
1
7
5
9
4
6
Kernel
running
Zombie
Sleep in
memory
User
running
Ready to run
in memory
Exit
Preempted
Sleep
swapped
Ready to run
swapped
Created
System call interrupt
Return
Not enough memory
Preempt
wakeup
wakeup
Swap out
Swap out Enough memory
Fork
Return to user
Swap in
Sleep
3
Unix Process State Transition
 Nine process states are recognized by the Unix System V operating
system
 Unix employ two running states to indicate weather the process is
executing in user mode or kernel mode
 Unix process states are;
 User running
 Executing in user mode
 Kernel running
 Executing in kernel mode
 Ready to run (in memory)
 Ready to run as soon as kernel schedules it
 Sleeping in memory
 Unable to run until an event occurs
 Ready to run (swapped)
 The swapper must swap the process into memory before the kernel can
schedules it to execute
Unix Process State Transition
 Sleeping (swapped)
 The process is waiting for an event, swapped to a disk
 Preempted
 Process is returning from kernel to user mode, but the kernel preempts it and does a
context switch to schedule another process
 Created
 Process is newly created and not yet ready to run
 Zombie
 Process no longer exist, but it leaves a record for its parent process
 A distinction is made between two states; ready to run, in memory and
preempted
 These are essentially the same states as indicated by the dotted line
 Preemption can occur when a process is about to move from kernel mode
to user mode

More Related Content

Similar to OS - Chapter # 3 for the development of os

My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process managementBabasab Patil
 
My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process managementBabasab Patil
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptxDiptoRoy21
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptMohammad Almuiet
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringYogesh Santhan
 
Chapter two process.pptx
Chapter two process.pptxChapter two process.pptx
Chapter two process.pptxMezigebuMelese1
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1New Era University
 
Process management
Process managementProcess management
Process managementBirju Tank
 
OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)Muhammad Osama
 
Operating system
Operating systemOperating system
Operating systemMark Muhama
 
Operating System 3
Operating System 3Operating System 3
Operating System 3tech2click
 

Similar to OS - Chapter # 3 for the development of os (20)

My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process management
 
My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process management
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.ppt
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - Engineering
 
CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2
 
Chapter two process.pptx
Chapter two process.pptxChapter two process.pptx
Chapter two process.pptx
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1
 
unit-2.pdf
unit-2.pdfunit-2.pdf
unit-2.pdf
 
Process management
Process managementProcess management
Process management
 
Processing management
Processing managementProcessing management
Processing management
 
OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)
 
Operating system
Operating systemOperating system
Operating system
 
3 processes
3 processes3 processes
3 processes
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
 
Os
OsOs
Os
 
Os
OsOs
Os
 

Recently uploaded

VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...Call Girls in Nagpur High Profile
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝soniya singh
 
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一ga6c6bdl
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Pooja Nehwal
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsappssapnasaifi408
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...anilsa9823
 
Dubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai WisteriaDubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai WisteriaUnited Arab Emirates
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsPooja Nehwal
 
Call Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile serviceCall Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile servicerehmti665
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样
原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样
原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样qaffana
 
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...ranjana rawat
 
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...nagunakhan
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escortsranjana rawat
 

Recently uploaded (20)

VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
VVIP Pune Call Girls Warje (7001035870) Pune Escorts Nearby with Complete Sat...
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
Call Girls in Dwarka Sub City 💯Call Us 🔝8264348440🔝
 
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
 
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
Call Girls in Thane 9892124323, Vashi cAll girls Serivces Juhu Escorts, powai...
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
 
Dubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai WisteriaDubai Call Girls O528786472 Call Girls In Dubai Wisteria
Dubai Call Girls O528786472 Call Girls In Dubai Wisteria
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
🔝 9953056974🔝 Delhi Call Girls in Ajmeri Gate
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call Girls
 
Call Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile serviceCall Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile service
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样
原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样
原版制作美国天普大学毕业证(本硕)tu毕业证明原版一模一样
 
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
(MEGHA) Hinjewadi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune E...
 
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
 
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
Slim Call Girls Service Badshah Nagar * 9548273370 Naughty Call Girls Service...
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
 

OS - Chapter # 3 for the development of os

  • 2. Chapter 3 - Outline  Process Concept  Program vs Process  Process Control Block  Process Table  Context Switch  Process states  Process states transitions  Process life cycle  Five state process model  Unix process state transition diagram
  • 3. Process Concept  A process is basically a program in execution  or that which a processor executes  A process is unit of work in a system  A process is an activity performed by a system  It may be program’s data, program counter, pointer or register used in a program  A process uses resources like CPU, memory, files and I/O devices  Operating system processes execute system code and user processes executes user code
  • 4. Program vs Process  A program is a passive entity  A process is a dynamic entity represented by the values stored in registers, memory, program counters etc.  A program does not compete for the computing resources whereas a process does  One program can have several processes  Consider multiple users executing the same program
  • 5. Process Concept  Multiple parts  The program code, also called text section  Current activity including program counter, processor registers  Stack containing temporary data  Function parameters, return addresses, local variables  Data section containing global variables  Heap containing memory dynamically allocated during run time
  • 6. Process Concept ()  Process idea was first used in Multics  All programming OS, such as Windows NT, or MVS (multiple virtual storage) were built around the concept of process  Major requirements that the OS must meet can all be expressed with reference to process  OS must interleave the execution of a number of processes to maximize processor use  OS must allocate resources to process in confirming to a specify policy  e.g. certain functions or applications are of higher priority  at the same time avoiding deadlock  OS may support inter-process communication
  • 7. Process Control Block (PCB)  When a new user program is initiated  OS creates a data structure, called Process Control Block (PCB), which gives substance to the process and serves to control it  Each process is represented by its own process control block  PCB is a data block or record containing information associated with a specified process  Allows the OS to locate all key information about a process  When the OS switches the attention of the CPU among various active processes  It uses the same area in PCB to hold the information  That information used to restart process when the process next gets CPU  Process control block is also called task control block
  • 8. Process Control Block (PCB)  PCB contains following information about process  Current state of the process  Unique identification of process  A pointer to process parent  Pointer to process’s child processes  The process’s priority  Pointer to locate the process memory  Pointer to allocate resources  The register save area – CPU register  The processor it is running on  Accounting information  I/O state information
  • 9. Process Control Block (PCB) Pointer Process state Process number Program counter Registers Memory limits List of open files . . .
  • 10. Process Table  OS maintains the process table with one entry per process  This entry contains information about process’s  state  its program counter  stack pointer  memory allocation  the status of its open file  its accounting and scheduling information  its priority
  • 11. The Shell  It is a command interpreter  It is a process which starts by typing a command at prompt  It provides an interface to the OS for the user  A facility for online users rather than batch  Command can be entered  directly at an online terminal  through shell program or script  a text file having series of commands forms a script  DOS shell is alternative as screen oriented interface
  • 12. The Shell  In Unix when any user login in, a shell is started up  It starts up as soon as user types some thing at command prompt, e.g. date  The shell creates a child process and run the date program  When child is running shell waits for its termination  When child finishes, the shell types $ prompt again and wait for next command
  • 13. The Shell Shell Process Process executing grep File studentInfo $ grep First studentInfo First
  • 14. Operations on Process ()  A system managing processes may perform following operations  Create a process  Destroy a process  Suspend a process  Resume a process  Block a process  Wakeup a process  Dispatch a process  Change process’s priority  Enable a process to communicate with other processes  For long term suspension, process’s resources should be free  Changing the priority of process normally involved modifying the priority value in PCB
  • 15. Process Creation & Termination  A process may create other processes  When a process creates a new process  The creator process is called the parent process  Created process is called the child process  Act of creating a process is called spawning a process  A child process may share the resources of its parent process
  • 16. Process Creation & Termination  A parent may wait for its child process to terminate before resuming or may run concurrently with the child process  A child process may run the same program as that of its parent or may run a separate program  In DOS, parent and child process do not run in parallel and parent process will suspend itself till child has finished
  • 17. Process Creation & Termination ()  When a process is created the following operations are performed  Process naming (process id)  Creates the process control block  Insert it in process table  Determine the process initial priority  Allocate the process’s initial resources  Allocate the address space to be used by the process  When a process is destroyed following operations are performed  Its resources are returned to the system  Its process control block is erased  It is purged from any system list or table
  • 18. Reasons for Process Creation 1. New batch job  In a batch environment, a process is created in response to the submission of a job 2. Interactive log on  A user at a terminal logs on to the system 3. Created by OS to provide a service  OS can create a process to perform a function on behalf of a user program, without user having to wait, e.g. printing 4. Spawned by existing process  A user program can create a number of processes  Typically related processes need to communicate and cooperate each other  Achieving this cooperation is a difficult task for the programmer of OS
  • 19. Reasons for Process Termination  There must be some means for a process to indicate its completion  A batch job should include a halt instruction, which generates an interrupts to alert the OS that a process has completed  For an interactive application, the action of the user will indicate whether the process is completed
  • 20. Reasons for Process Termination Following are the possible reasons for process termination; 1. Normal termination  The process executes an OS service call to indicate that it has completed running 2. Time limit exceeds  The process has run longer than the specified total time limit which includes  total time elapsed  amount of time spent executing  in case of interactive process, he amount of time since the user last provided any input 3. Memory unavailable  The process requires more memory than the system can provide
  • 21. Reasons for Process Termination 4. Bounds violation  The process tries to access the memory locations that is not allowed to access 5. Protection error  The process attempt to use a file that is not allowed to use or,  It tries to use it in improper fashion, such as writing to a read only file 6. Arithmetic error  The process tries a prohibited computation such as division by zero 7. Time overrun  The process has waited longer than specified maximum for a certain events to occur
  • 22. Reasons for Process Termination 8. I/O failure  An error occur in input or output, such as  inability to find a file  failure to read a write after a specified maximum no of tries (when, e.g. a defective area is encountered on a diskette) or  invalid operation (such as reading from the line printer) 9. Invalid instruction  The process attempts to execute a non-existent instruction (often a result of branching into a data area and attempting to execute data) 10. Privileged instruction  The process attempts to use an instruction reserved for the operating system
  • 23. Reasons for Process Termination () 11. Data misuse  A piece of data is of the wrong type or is not initialized 12. OS or operator intervention  For some reason, the operator or the OS has terminated the process (e.g. if a deadlock exists) 13. Parent termination  When a parent terminates, the OS should be design to automatically terminate all the offspring of that parent 14. Parent request  A parent process typically has the authority to terminate any of its offspring
  • 24. Process States  A process may have the following three states  Running  Instructions are being executed  Waiting/Blocked  The process is waiting for some event to occur (may be I/O completion)  Ready  The process is waiting to be assigned to processor  At any instant a process is in one and only one of three states  Process entering the system must go initially into the ready state  Process can only enter the running state via the ready state  Many OS are constructed using only these three states  However, there is good justification for adding additional states to the model
  • 26. Process State Transitions  Transition-1:  Occurs when a process cannot continue may be due to I/O request  Transition-2:  Request when scheduler decides that the running process has run long enough , and it’s the time to give CPU to other processes in ready state  Transition-3:  Occurs when all the other process have had their CPU time and its time for the first process to run again  Transition-4:  Occurs when external event for which process was waiting happens. If no other process is running at that time, transition-3 will be triggered and the process will start execution
  • 27. Process State Transitions Ready Running Blocked 2 1 3 4  The four transitions can be indicated as follows  Block running  block  Timerunout running  ready  Dispatch ready  running  Wakeup block  ready
  • 28. Context Switch  Context switching is the procedure of switching of process from processor to memory and vice versa in a multiprogramming environment  When CPU switches to another process  The system must save the state of the old process  Load the saved state of the new process  Context switch involves storing and loading the values of each of the process’s control block, and process registers, such as;  The program counter  Index register  General register  Stack pointer etc
  • 29. Context Switch  Context switch is pure overhead  The system does no useful work while switching  Context switch time depends on hardware support e.g, memory speed, the number of registers etc.  Its range is from 1 to 100 microsecond  This speed vary from system to system
  • 31. Process Life Cycle  As a process executes, it changes state  new: The process is being created  running: Instructions are being executed  waiting: The process is waiting for some event to occur  ready: The process is waiting to be assigned to a process  terminated: The process has finished execution
  • 33. Process Life Cycle  Assume that process is running with a Unix operating system with no user process  Various events in life of processes within a multiprogramming system are given below;  User using the shell command interpreter, types in a program name, say solvit  The shell finds this program and program code will be loaded  A system call will be used to generate a process corresponding to the execution of the solvit program  The OS creates process control block in the memory  The process solvit will now begin to run – the process is said to be in running state  After a while, solvit needs to read some data from a disk file and issue an appropriate system call  The process is now said to be in the blocked state
  • 34. Process Life Cycle  In the mean time, another user wants to run a program called myprog  A new process is created for myprog and since solvit is currently idle, execution begins; myprog is now running  The I/O delay which is blocking solvit now ends and solvit wants to restart; solvit is now said to be in ready state  The OS scheduler now decides that myprog has enough processor time (Timeout) and moves it into the ready queue  Solvit is restarted and enters the running state once more  Switching between active processes, waiting for I/O transfer etc. will continue for the life of the processes  Eventually, solvit completes its tasks and terminates; it leaves the running state and disappears from the system  Similarly myprog terminates
  • 35. Five State Process Model Blocked Suspended Admit I/O Completion Suspended I/O Request Release Time-out Dispatch Suspended Resume Admit Resume Suspended Running Blocked Ready Ready Suspended
  • 36. Five State Process Model  There are two queues; a ready queue and a blocked queue  OS chooses a process the ready queue to run  In the absence of any priority scheme, this can be a simple FIFO  A running process is removed from execution, it is either  Terminated  Time quantum is over  Performed I/O  After I/O completion processes in blocked queue are moved to ready queue  When an event occurs, the OS must scan the entire blocked queue  In a large OS, there could be hundreds or even thousands of processes in that queue  It would be more efficient to have a number of queues, one for each event  When an event occurs, the entire list of processes in the appropriate queue can be moved to the ready state
  • 37. Five State Process Model  Consider a system that does not employ virtual memory  Each process to be executed must be loaded fully into memory  In multiple blocked queuing model, all the processes in all the queues must be resident in memory  Memory holds multiple processes  Solutions  Expand the memory  it has own flaw  Cost associated with expansion  Swapping  Moving part or all of a process (blocked) from memory to disk (suspended queue)  The space that is freed up in memory can be then be used to bring another process  When a process is suspended, it becomes dormant and merely waits until it is resumed by the system or user
  • 38. Five State Process Model  A process can be suspended for the following reasons;  Process being swapped put of the memory by the memory management system in order to free memory for higher priority processes  A user may wish to suspend execution of a program for purpose of debugging a program  Process investigates previous effects of the process  Processes designed to run periodically to monitor system usage  The OS may suspend a background or utility process or a process that is suspected of causing a problem  The process can be suspended while in running, ready or blocked state
  • 39. Unix Process State Transition 2 8 1 7 5 9 4 6 Kernel running Zombie Sleep in memory User running Ready to run in memory Exit Preempted Sleep swapped Ready to run swapped Created System call interrupt Return Not enough memory Preempt wakeup wakeup Swap out Swap out Enough memory Fork Return to user Swap in Sleep 3
  • 40. Unix Process State Transition  Nine process states are recognized by the Unix System V operating system  Unix employ two running states to indicate weather the process is executing in user mode or kernel mode  Unix process states are;  User running  Executing in user mode  Kernel running  Executing in kernel mode  Ready to run (in memory)  Ready to run as soon as kernel schedules it  Sleeping in memory  Unable to run until an event occurs  Ready to run (swapped)  The swapper must swap the process into memory before the kernel can schedules it to execute
  • 41. Unix Process State Transition  Sleeping (swapped)  The process is waiting for an event, swapped to a disk  Preempted  Process is returning from kernel to user mode, but the kernel preempts it and does a context switch to schedule another process  Created  Process is newly created and not yet ready to run  Zombie  Process no longer exist, but it leaves a record for its parent process  A distinction is made between two states; ready to run, in memory and preempted  These are essentially the same states as indicated by the dotted line  Preemption can occur when a process is about to move from kernel mode to user mode