You are on page 1of 16

PROCESS MANAGEMENT

(OPERATIONS ON PROCESSES)
SAIQA ASGHAR

Tuesday, October
1
31, 2017
CONTEN

OPERATION ON PROCESSES
PROCESS CREATION
PROCESS TERMINATION
COOPERATIONG PROCESSES
ADVANTAGES OF COOPERATING PROCESS
PRODUCER-CONSUMER PROBLEM
ADDITIONAL INFORMATION

Tuesday, October
2
31, 2017
OPERATIONS ON PROCESSES

The processes in the system can execute concurrently, and


they must be created and deleted dynamically. Thus, the
operating system must provide a mechanism (or facility)
for process creation and termination.

Tuesday, October
3
31, 2017
PROCESS CREATION

A process may create several new processes, via a create-


process system call.
The creating process is called a parent process, whereas
the new processes are called the children of that process.
Parent process create children processes, which, in turn
create other processes, forming a tree of processes.

Tuesday, October
4
31, 2017
RESOURCE SHARING

Parent and children share all resources


Children share subset of parents resources
Parent and child share no resources
In general, a process will need certain resources (such as CPU time,
memory, files, I/O devices) to accomplish its task.
When a process creates a child process, that child process may be able
to obtain its resources directly from the parent. OR It must obtain its
own resources.
The parent may have to partition its resources among its children, or it
may be able to share some resources (such as memory or files) among
several of its children. Restricting a child process to a subset of the
parent's resources prevents any process from overloading the system
by creating too many child processes.
Tuesday, October
5
31, 2017
EXECUTION

When a process creates a new process, two possibilities


exist in terms of execution:
1. The parent continues to execute concurrently with its
children.
2. The parent waits until some or all of its children have
terminated.

Tuesday, October
6
31, 2017
ADDRESS SPACE

Child duplicate of parent.


It would allow the child to communicate easily as they share same
address space.

Child has a program loaded into the address space.


Typically we want the child to do something different from parent.
This makes it more difficult for the child and parent to
communicate since they have nothing in common.

Tuesday, October
7
31, 2017
PROCESS TERMINATION

A process terminates when it finishes executing its final


statement and asks the operating system to delete it by
using the exit() system call.
At that point, the child process may return data (output) to
its parent process (via the wait system call). All the
resources of the process-including physical and virtual
memory, open files, and I/O buffers-are de-allocated by the
operating system.

Tuesday, October
8
31, 2017
CHILD PROCESS TERMINATION

Parent may terminate execution of children processes using


abort() system call. This may occur due to following
reasons:
1. Child has asked for too many resources.
2. Task assigned to child is no longer required.
3. If the parent is terminating.

Tuesday, October
9
31, 2017
COOPERATING PROCESSES

The concurrent processes executing in the operating


system may be either independent processes or cooperating
processes.
Independent process: A process that cannot affect or be
affected by the execution of other processes. It does not
share data with other processes.
Cooperating process: A process that can be affected or be
affected by execution of other processes. It shares data
with other processes.

Tuesday, October
10
31, 2017
ADVANTAGES OF COOPERATION PROCESSES

Information sharing:
Since several users may be interested in the same piece of information
(for instance a shared file), we must provide an environment to allow
concurrent access to these types of resources.

Computation speedup:
If we want a particular task to run faster, we must break it into subtasks,
each of which will be executing in parallel on several processors.

Modularity:
The solution of a problem is structured into parts with well-defined
interfaces, and where the parts run in parallel.

Convenience:
Even an individual user may have many tasks on which to work at one
time. For instance, a user may be editing, printing, and compiling in
parallel.

Tuesday, October
11
31, 2017
PRODUCER-CONSUMER EXAMPLE

Concurrent execution of cooperating processes requires


mechanisms that allow processes to communicate with one
another and to synchronize their actions e.g. writing and
reading the same piece of data.
To illustrate the concept of cooperating processes, let us
consider the Producer Consumer Problem, which is a
common example for cooperating processes.

Tuesday, October
12
31, 2017
Producer-Consumer Example

Producer process
It produces information that will be consumed by consumer.

Consumer process
It consumes information produced by the producer.

Tuesday, October
13
31, 2017
Example..

To allow producer and consumer processes to run


concurrently, we must have available a buffer of items that
can be filled by the producer and emptied by the consumer.
A producer can produce one item while the consumer is
consuming another item.
The producer and consumer must be synchronized, so that
the consumer does not try to consume an item that has not
yet been produced. In this situation, the consumer must
wait until an item is produced.

Tuesday, October
14
31, 2017
There are two versions of the producer.
First Version:
The producer can produce infinite amount of items. This is called
Unbounded Buffer Producer Consumer Problem.

Second Version:
There is a fixed limit to the buffer size. When the buffer is full, the
producer must wait until there is some space in buffer before it can
produce new item.

Tuesday, October
15
31, 2017
ADDITIONAL INFORMATION

An address space is a range of valid addresses in memory


that are available for a program or process. That is, it is the
memory that a program or process can access. The memory
can be either physical or virtual and is used for executing
instructions and storing data
Buffer is a area of a physical memory storage used to
temporarily store data while it is being moved from one
place to another. A buffer may be used when moving data
between processes within a computer.

Tuesday, October
16
31, 2017

You might also like