Operations on Process:
In most of the operating systems, a processor supports at
least two modes of execution:
1.
User mode – it is a less privileged mode. All
user programs run in this mode.
2.
Kernel mode – it is a more privileged mode. All the OS related tasks are executed in
this mode. A kernel mode is also called as a system mode or control mode.
The mode of execution is indicated by a bit in the program
status word (PSW).
1.
Process Creation:
An OS creates a new process with the specified or default
attributes and an identifier. A process
may create several new sub-processes.
Syntax for new process creation: CREATE (ProcessID,
attributes), where CREATE is a system call. They have two types - Parent process and Child process.
A parent process is a creating process whereas; a child
process is created by the parent process. A child process may create another
sub processes for which it acts as a parent.
As such, it forms a tree of processes. When OS issues a CREATE system
call, it obtains a new PCB from the pool of free memory, fills the fields with parameters
(provided and default) and insert the PCB into the ready list. Thus, this makes
the specified process eligible for execution.
Commonly required parameters when a process is created
include:
·
priority
of a process
·
privilege
level
·
memory
resources
·
access
permissions
·
memory
protection information, etc.
Moreover, a process will require certain resources such as
CPU time, memory, files and IO devices to complete its operation. When a process creates a sub-process, it may
obtain its resources either directly from an OS or it uses the resources of
parent process.
When a parent process creates a new child process, they can
execute in one of the following way:
1.
Parent
continues to execute concurrently with its child.
2.
Parent
waits until some or all of its child processes have terminated.
Similarly, with regards to an address space, the two
possibilities that can occur:
1.
Child
process is a duplicate of the parent process.
2.
Child
process has a program loaded into it.
Following
are the possible reasons for process creation:
1. New batch job: a batch job is provided
to OS.
2. Interactive logon: user at a terminal
logs on to the system.
3. Created by OS on behalf of a user
program.
2.
Process Termination :
A DELETE system call is used for terminating a process. A process can terminate itself or it may be
terminated by another process using an appropriate system call. When a process
is terminated, OS reclaim all the resources that were allocated to it and close
all files opened by that process. Further, OS removes PCB and returns it to the
free pool. The delete service is a normally invoked as a part of orderly program
termination.
Possible
reasons for process termination are as follows:
1.
A
process has completed its normal operation.
2.
When
parent terminates, it terminates the child process.
3.
A
process has run longer than the specified total time length.
4.
Process
requires more memory than the system can provide.
5.
Process
tries to access un-allowed memory location.
6.
An
attempt to execute invalid instruction.
7.
Privileged
instruction- process tries to use an instruction reserved for OS only.
1.
Protection
error - process attempts to use a resource that it is not allowed to use.
2.
If
a deadlock exists in the system, an OS may terminate a process.
3.
Data
misuse - a piece of data is of wrong type or is not initialised.
Concurrent Processes:
The two processes are said to be serial processes, if the
execution of one must complete before the execution of another process starts. The
two processes are called concurrent, if they are not serial and their execution
can overlap in time.
Consider the following figure:
In Fig (a), process P1 starts its execution at time T0;
process P2 starts its execution only after process P1 has finished its
execution. Similarly, process P3 starts
its execution only after process P2 has finished its execution. Thus, these processes are said to be serial processes.
Now, consider Fig (b), where the execution time of processes P1,
P2 and P3 are overlapped. Therefore, they are called as concurrent processes.
No comments:
Post a Comment