Sie sind auf Seite 1von 32

Process Management

Operating Systems

What is a Process?

Process
y

A process can be thought of a program in execution.


x It will need some resources such as CPU time, Memory, Files, and I/O devices to accomplish its task.

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.

What is process management?

It is the fundamental task of an operating system.

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.

Process State Models

TwoTwo-state Process Model


y

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).

TwoTwo-state process model


y

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

TwoTwo-state process model


y

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.

Three State process


y

Has the following process sates:


Running process that is currently using the CPU Ready runnable but is on hold until the CPU is available. Blocked unable to run until an external event occurs

Five state process model


y

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 and Termination

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 are terminated by any of the ff. set of events:


Normal completion a process issues a system call that it has finished its work. Time limit exceeded the process exeeds its time limit. Memory unavailable there is insufficient memory than what is being required by the process.

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

Implementations when creating a new process


The parent continues to execute concurrently with the child. The parent waits until all its children have terminated.

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.

The concurrent process may either be INDEPENDENT process or COOPERATING process.

Independent Process Characteristics


y

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.

Cooperating Process Characteristics


If it can affect or be affected by other processes. y The result of its execution cannot be predicted in advance. Since it depends on relative execution sequence. y The result of its execution is nondeterministic since it will not always be the same for the same input.
y

Das könnte Ihnen auch gefallen