6. process
TRANSCRIPT
-
8/11/2019 6. process
1/24
The Process
Ami Tri Cahyadi
-
8/11/2019 6. process
2/24
Many definitions have been given for theterm
process, including
A program in execution An instance of a program running on a computer
The entity that can be assigned to and executedon a processor
A unit of activity characterized by a single
sequential thread of execution, a current state,and an associated set of system resources
-
8/11/2019 6. process
3/24
3
Component of Process
An executable program
The associated data needed by theprogram (variables,work space, buffers,
etc.) The execution context of the program
-
8/11/2019 6. process
4/24
An address space
A program
A execution engine (program
counter, ...)
Data
Resources
Process control block (PCB) withprocess identifier (PID)
-
8/11/2019 6. process
5/24
The execution context, or processstate, is the internal data by whichthe OS is able to supervise and control
the process. This internal information is separatedfrom the process, because the OS hasinformation not permitted to the
process.
-
8/11/2019 6. process
6/24
-
8/11/2019 6. process
7/24
-
8/11/2019 6. process
8/24
Classic Process (one
thread)
-
8/11/2019 6. process
9/24
Address Space
Each process views its memory as acontiguous set of logical memoryaddresses. The operating system
manages the translation of logicaladdresses to the physical memoryaddresses of the computer.
-
8/11/2019 6. process
10/24
-
8/11/2019 6. process
11/24
Process Control Block
(PCB)
The process control block is a data structurefor each process holding:
Register values
Logical state Page map table mapping logical addresses tophysical addresses
Type & location of resources it holds List of resources it needs Parent process identification Security keys etc.
-
8/11/2019 6. process
12/24
Process Creation
At system boot time, one user levelprocess is created. In Unix, this processis called init.
In Windows, it is the System IdleProcess. This process is the parent orgrand-parent of all other processes.
New Child Processes are created byanother process (the Parent Process).
-
8/11/2019 6. process
13/24
Windows Process Creation
-
8/11/2019 6. process
14/24
14
Unix Process Creation
Unix fork() creates a process
Creates a new address space
Copies text, data, & stack into new adressspace
Provides child with access to open files
Unix exec() allows a child to run a newprogram
Unix wait() allows a parent to wait for achild to terminate
-
8/11/2019 6. process
15/24
15
-
8/11/2019 6. process
16/24
int pidValue;
...
pidValue = fork(); /* Creates a child process */
if(pidValue == 0) {
/* pidValue is 0 for child, nonzero for parent */
/* The child executes this code concurrently with parent */ childsPlay(...); /* A procedure linked into a.out */
exit(0);
}
/* The parent executes this code concurrently with child */
parentsWork(...);
wait(...);
...
-
8/11/2019 6. process
17/24
Multi-threaded Process
The simple model of a process containingonly one thread, is referred to as a classicprocess. Modern operating systems alsosupport processes with multiple threads.
Each thread of a single process can use theprocess global data with synchronizationresources to easily communicate with otherthreads. Multi-threaded programs run moreefficiently and use less resources than a
program that creates multiple processes toaccomplish the same task.
-
8/11/2019 6. process
18/24
-
8/11/2019 6. process
19/24
19
The Process Managers Job
The responsibilities of the process managerinclude:
Process creation and termination
Thread creation and termination Process/thread synchronization Resource allocation Resource protection Cooperation with the device manager toimplement I/O
Implementation of the address space Process Scheduling
-
8/11/2019 6. process
20/24
Process Finite State
Diagrams
Simple FSM
-
8/11/2019 6. process
21/24
Unix FSM
-
8/11/2019 6. process
22/24
Windows FSM
-
8/11/2019 6. process
23/24
-
8/11/2019 6. process
24/24
24
Process Resource
Allocation
If a process requests a resource that is already in use, the process is held in a
queue until the resource becomes available.