Beruflich Dokumente
Kultur Dokumente
Operating Systems
What is a Process?
Process
y
It is an active entity which means, it is a set of instruction waiting in memory or having execution.
So a program by itself is not a process
Process
Process
Process
y
A Process is the unit of work in a system. Such, a computer system consist of a collection of processes:
x Operating system processes execute system code, and user processes execute user code.
Process Management
y
The operating system is responsible for the following activities in connection with process management:
x Creation and deletion of both user & system process; scheduling of process; and the provision of mechanisms for synchronization, communication, and deadlock handling process.
As a process Execute, it changes state. The current activity of a process partly defines its state. A process is actually a cycle of CPU execution (CPU burst) and I/O wait (I/O burst).
A process is more than the program code and the current activity. It also includes:
x Process stack containing temporary data(such as subroutine parameters, return addresses and local variables) x Data section containing local variables
It is the simplest process model. This model upholds the view that at any given time a process is either being executed by a processor or not.
This is the most popular model and composes of the following states:
New the process is being created Running the CPU is executing the instruction Waiting the process is waiting for some event to occur (such as an I/O completion) Ready the process is waiting for the OS to assign a processor to it. Terminated the process has finished execution
Process Creation
y
4 principal Events:
System Initialization Process Spawning by an Executing Process User Request To create new process Initialization of a batch Job
Process Termination
y
Process Termination
Bounds Violation the process tries to access a restricted memory location. Protection error the process attempts to access a restricted resource/file or uses it in an improper fashion. Arithmetic error the process performs illegal operation such as division by zero. Time overrun occurs when a process have to wait more than the maximum time for an event to take place.
Process Termination
I/O failure occurs when an error is encountered in an I/O device. y Invalid instruction the process tries to execute a non existent instruction. y Privileged instruction occurs when a process attempts to execute an instruction reserved for the OS alone. y Data misuse happens when the data is of the wrong type or not initialized.
y
Process Termination
Operator or OS intervention OS terminates a process if a deadlock occurs y Parent Termination when a parent terminates its offsprings are tagged along. Known as CASCADING TERMINATION y Parent request the parent process is authorized to terminate any of its offsprings.
y
Process Implementation
y
Each process is represented in the OS by a Process Control Block (PCB) A PCB is a data block or record containing many pieces of information associated with a specific process including:
Process State the state maybe new, ready, running or halted. y Program counter indicates the address of the next instruction to be executed for this process. y CPU registers these include accumulators, index registers, stack pointers and general purpose registers, plus any condition-code information.
y
CPU scheduling Information this information includes a process priority, pointers to scheduling queues and any other scheduling parameters. y Memory management information this information includes limit registers and page tables.
y
Accounting information this information includes the amount of CPU and real time used, time limits, account no., job or process no. and so on. y I/O Status information this info includes outstanding I/O request. I/O devices allocated to this process, a list of open files and so on.
y
The PCB simply serves as the repository for any information that may vary from process to process.
Concurrent Processes
Concurrent Processes
Many processed may be ,multitasked on the CPU. A process may create a new process via create-process system call, during the course of execution. y The creating process is the parent process whereas the new process is the child. y The child can also create a new process. y This Phenomenon is know as Process Group.
y
A process terminates when it finishes its last statement and asks the OS to delete it using the EXIT system call.
A parent may terminate its child for the ff. reasons:
x The child exceeds the usage of the resources it has been allocated x The task assigned to the child is no longer needed. x The parent is exiting.
Its execution is deterministic. (the result depends solely on input state) The execution is reproducible; that is the result of the execution will always be the same for the same input. Its execution can be stopped and restarted without causing ill effects.