Professional Documents
Culture Documents
PROCESS MANAGEMENT
2.1 The Process Concept
2.2 Process Life Cycles
2.3 Process Control
2.4 Threads
1 / 15
CH-02: Process Management ...
2 / 15
CH-02: Process Management ...
2 / 15
CH-02: Process Management ...
2 / 15
CH-02: Process Management ...
2 / 15
CH-02: Process Management ...
Process....
Process is represented by...
Data section: Which contains global variables.
Heap: Which is memory that is dynamically allocated during process run
time
A program by itself is not a process;
its just Passive entity; whereas a process is an active entity
When does program become process?
⇓
♣ When an executable file is loaded into memory
Two common techniques for loading
Double-clicking an icon representing the executable file.
Entering the name of the executable file on the command line
3 / 15
CH-02: Process Management ...
When A program executes it passes via different states.
Process states:
1 New- The process is being created.
2 Running- Instructions are being executed.
3 Waiting - The process is waiting for some event to occur (such as an I/O
completion or reception of a signal).
4 Ready- The process is waiting to be assigned to a processor.
5 Terminated- The process has finished execution
4 / 15
CH-02: Process Management ...
When A program executes it passes via different states.
Process states:
1 New- The process is being created.
2 Running- Instructions are being executed.
3 Waiting - The process is waiting for some event to occur (such as an I/O
completion or reception of a signal).
4 Ready- The process is waiting to be assigned to a processor.
5 Terminated- The process has finished execution
4 / 15
CH-02: Process Management ...
PCB
is a data structure maintained by the operating system for every processes.
identified by PID.
It contains Multitude information associated with a specific process. What
informations?
5 / 15
CH-02: Process Management ...
PCB
is a data structure maintained by the operating system for every processes.
identified by PID.
It contains Multitude information associated with a specific process. What
informations?
Process State: current state of processes→ ready, running, waiting or Other.
Program counter: Address of the next instruction to be executed for this
process.
Process ID: an Identifier for each processes.
Pointer : which points to the parent process.
CPU registers: kind of memory where processes need to be stored for
execution for running process.
CPU-scheduling information: includes process priority and other scheduling
info. required to schedule the process.
Accounting information: This includes the amount of CPU used for process
execution, time limit, execution ID etc.
I/O status information: This information includes the list of I/O devices
allocated to the process, a list of open files, and so on.
5 / 15
CH-02: Process Management ...
A process is a program that performs a single thread of execution.
This single thread of control allows the process to perform only one task
at a time.
6 / 15
CH-02: Process Management ...
A process is a program that performs a single thread of execution.
This single thread of control allows the process to perform only one task
at a time.
MULTIPROGRAMMING - a process to have multiple threads of execution
⇒ to perform more than one task at a time
• What is Thread then ?
Thread is ..
A basic unit for CPU Utilization. OR
are lightweight processes.
also a software approach to improve performance of operating system by
reducing the Overhead of classical Process.
Each threads belongs to one process and represent a separate flow of
execution.
It comprises a thread ID, a program counter, a register set, and a stack.
BUT, Shares the code section, data section, and other operating-system
resources.
A process with Single threads of control ⇒ Single-threaded process.
A process with multiple threads of control ⇒ Multi-threaded process.
6 / 15
CH-02: Process Management ...
7 / 15
CH-02: Process Management ...
Benefits Of Multi-threaded process!
Responsiveness
Resource sharing
Economy
Scalability
I How many processor your Machine has?
⇓
♣ Is it core i3, core i5, core i7! W@ is that?
8 / 15
CH-02: Process Management ...
Benefits Of Multi-threaded process!
Responsiveness
Resource sharing
Economy
Scalability
I How many processor your Machine has?
⇓
♣ Is it core i3, core i5, core i7! W@ is that? ⇒ Multicore Programming
8 / 15
CH-02: Process Management ...
Benefits Of Multi-threaded process!
Responsiveness
Resource sharing
Economy
Scalability
I How many processor your Machine has?
⇓
♣ Is it core i3, core i5, core i7! W@ is that? ⇒ Multicore Programming
Multicore Programming
A programming in system design to place multiple computing cores on a
single chip, where each core appears as a separate processor to the
operating system.
Utilized for deployment on Multicore processor and Multiprocessor systems
Multicore processor system is a single processor with multiple execution cores in
one chip.
Multiprocessor system has multiple processors on the motherboard or chip
Multithreaded programming provides a mechanism for more efficient use of
multiple cores and improved concurrency.
CONCURRENCY and PARALLALISM ⇒ way of executing process in Multi-core
systems
8 / 15
CH-02: Process Management ...
9 / 15
CH-02: Process Management ...
9 / 15
CH-02: Process Management ...
Thread libraries...
1 POSIX Pthreads:
Stands for Portable Operating System Interface
⇓
is a set of standard operating system interfaces based on the Unix
operating system
Pthreads refers to the POSIX standard defining an API for thread creation
and synchronization.
It is not Implementation rather its defines thread behavior.
2 Win32 Threads
The technique for creating threads using the Win32 thread library.
Header file must be included in case of using the Win32 API such thread
libraries, such as windows.h
3 Java Threads
The Java thread API allows thread creation and management directly in
Java programs.
Two techniques for creating threads:
Create a new class that is derived from the Thread class
To override its run() method.
10 / 15
CH-02: Process Management ...
11 / 15
CH-02: Process Management ...
12 / 15
CH-02: Process Management ...
Shared memory
A Region of memory that is shared by cooperating processes is established.
Processes can then exchange information by reading and writing data to the
shared region.
A Shared-memory region resides in the address space of the process creating
the shared-memory segment.
A Processes that wish to communicate using this shared-memory segment
must attach it to their address space
Is a solution for Producer-Consumer Problem.
13 / 15
CH-02: Process Management ...
Shared memory
A Region of memory that is shared by cooperating processes is established.
Processes can then exchange information by reading and writing data to the
shared region.
A Shared-memory region resides in the address space of the process creating
the shared-memory segment.
A Processes that wish to communicate using this shared-memory segment
must attach it to their address space
Is a solution for Producer-Consumer Problem.What is it?
Collection Of cooperating processes.
⇓
Producer process produces information that is consumed by a consumer process.
Message-Passing
13 / 15
CH-02: Process Management ...
Shared memory
A Region of memory that is shared by cooperating processes is established.
Processes can then exchange information by reading and writing data to the
shared region.
A Shared-memory region resides in the address space of the process creating
the shared-memory segment.
A Processes that wish to communicate using this shared-memory segment
must attach it to their address space
Is a solution for Producer-Consumer Problem.What is it?
Collection Of cooperating processes.
⇓
Producer process produces information that is consumed by a consumer process.
Message-Passing
Is a mechanism to allow processes to communicate and to synchronize their
actions without sharing the same address space
Relevant in distributed environment
⇓
The communicating processes may reside on different computers connected
by a network
Employe two operations
13 / 15
CH-02: Process Management ...
Shared memory
A Region of memory that is shared by cooperating processes is established.
Processes can then exchange information by reading and writing data to the
shared region.
A Shared-memory region resides in the address space of the process creating
the shared-memory segment.
A Processes that wish to communicate using this shared-memory segment
must attach it to their address space
Is a solution for Producer-Consumer Problem.What is it?
Collection Of cooperating processes.
⇓
Producer process produces information that is consumed by a consumer process.
Message-Passing
Is a mechanism to allow processes to communicate and to synchronize their
actions without sharing the same address space
Relevant in distributed environment
⇓
The communicating processes may reside on different computers connected
by a network
Employe two operations ⇒ send(message) and receive(message)
13 / 15
CH-02: Process Management ...
14 / 15
Thank you!
Questions + Suggestion ?!
15 / 15