teacher's notes - lec chapter 3 - process concept
TRANSCRIPT
-
7/25/2019 Teacher's Notes - Lec Chapter 3 - Process Concept
1/3
J.E.D.I.
1 Process Concept
1.1 ObjectivesThis chapter introduces the idea of processes. In particular, we will discuss the definition ofprocesses and the life cycle of a process.
1.2 Chapter OutlineThis chapter is divided into the following sections
Process Concept
Process Life Cycle
Process Control Bloc
1.3 Process Concept! process can "e defined as a progra# in e$ecution. %hen a progra#s is created, it e$ists#erely as instructions in a file until they are run "y the CP&. %hen a progra# is run, theinstructions are loaded into #ain #e#ory and thus "eco#es a process. In addition, you can
load a single copy of your progra# #ultiple ti#es in #e#ory. Even though the processes areall e$ecuting the sa#e instructions, they are e$ecuting independently of each other and are
therefore different processes.
'owever, a process is #ore than (ust the e$ecution of your progra#)s instructions. It alsoshould contain a pointer to the currently running instruction, space in #e#ory allocated for theprogra#)s data, and a list of operating syste# resources *such as files+ that the process is
currently using.
In the early days of co#puters, co#puters would only have a single process running with allCP& resources allocated to that single process. %ith the advent of #ultiprogra##ed "atchsyste#s, operating syste#s would have #ultiple processes fro# possi"ly #ultiple users allrunning concurrently. Thus an operating syste# should esta"lish controls on how theseprocesses interact with one another and with the operating syste#. The - should "e a"le to
address issues such as
Interprocess Co##unication / should processes "e a"le to influence each other)s
e$ecution0 %hat should a process do to co##unicate with another process0
CP& -cheduling / when and which process will "e given CP& ti#e, as the CP& can onlye$ecute instructions fro# once process at a ti#e
1esource !llocation / what resources are allocated to processes and when0 2or
e$a#ple, what if two processes decide to use the printer at the sa#e ti#e0
Process -ynchroni3ation / what if concurrently running processes #ust e$ecute in a
certain specific order0 2or e$a#ple, what if proper e$ecution of two processes#andates that process 4 should always write to a file "efore process 5 reads it0 %hat ifa process #ust not "e re#oved fro# CP& due to a critical operation0
Deadloc issue 6 what if two or #ore processes are waiting for each other to finish and
thus they never do. 'ow should the - handle this0
These issues are funda#ental to any operating syste#. %e will discuss these issues over thespan of the ne$t few chapters.
perating -yste#s 4
-
7/25/2019 Teacher's Notes - Lec Chapter 3 - Process Concept
2/3
J.E.D.I.
1.4 Process Life Cycle! process undergoes the following life cycle during the course of its e$ecution
7ew The newly created process is loaded into #e#ory
1eady The process is ready for e$ecution. It waits in the ready 8ueue until it is givenCP& ti#e.
1unning The processes is running on the CP&, currently e$ecuting progra# instructions
%aiting The process is waiting for I9.
Ter#inated The process has finished e$ecution and is waiting for the - to deallocate
it fro# #e#ory and to clear any used resources.
Process Life Cycle
Processes that are ready to e$ecute *in the ready state+ are placed in the ready 8ueue. nly asingle process can run on a single processor at a given ti#e. It is up to the CP& scheduler tochoose "etween processes in the ready 8ueue that will run ne$t on the CP&. The CP&
scheduler #ay also pre/e#pt or force a process in the running state to go "ac to the readystate in order to e$ecute another process, for e$a#ple, a process with a higher priority thanthe currently e$ecuting process.
! process undergoes a CP&/I9 "urst cycle. ! process on a CP& "urst is currently e$ecuting
instructions. !t so#e point in ti#e, it stops to wait for I9 to and fro# the user, ending its CP&"urst phase and entering the I9 "urst phase. Processes alternate "etween e$ecuting
instructions and waiting for additional input or sending output to the user.
%hen an I9 "urst happens, the process is #oved fro# the running state into the waiting
state. I9 is often an order of #agnitude slower than CP& e$ecution. 1ather than letting theCP& go idle for a long period of ti#e, the CP& scheduler sends processes in the I9 "urst into
perating -yste#s 5
-
7/25/2019 Teacher's Notes - Lec Chapter 3 - Process Concept
3/3
J.E.D.I.
the waiting state. This allows for other processes in the ready 8ueue to run their own CP&"urst, #aing sure that the CP& is not ept idle as #uch as possi"le. !fter a process hasfinished with its I9 "urst, it is sent "ac into the ready 8ueue.
1.5 Process Control BlockThe process control "loc is a data structure in the operating syste# which is used to descri"e
a process. :ostly, process control "locs contain the following infor#ation
Process identifier 6 usually a nu#"er to indicate what process this process control "loc
refers to.
1egister values 6 as a progra# e$ecutes, it changes values in the CP&)s registers. The
register values store the current CP& register values
Progra# counter 6 although this is a register value as well, we give this a special
#ention. The progra# counter indicates the currently e$ecuting instruction of the
process.
!ddress space 6 indicates the space in #e#ory the process is currently allocated.
Process accounting infor#ation 6 this includes process priority, the a#ount of ti#e used
"y the process in the CP&, or any additional infor#ation needed "y the -
I9 status infor#ation list of files or devices "eing used "y the process.
%hen a process is #oved fro# the running state to the waiting or ready state, the CP& #ustperfor# what is called a conte$t switch. In loading a different process into the CP& for
e$ecution, it #ust now what the register values are of the entering process, what space in#e#ory the process resides in, what instruction ne$t to e$ecute, etc. Basically, the - needs
the co#plete state of the process so that it will now where to start e$ecution fro#. Thisinfor#ation is what is stored in that process) PCB.
f course the e$iting process infor#ation #ust also "e stored in its PCB so that the CP& willnow where it left off when that process returns to the running state.
Context switch diagram
perating -yste#s ;