Content-Length: 3100284 | pFad | https://www.scribd.com/document/671431181/Module-8-Process-Management
1Module 8 Process Management
Module 8 Process Management
Module 8 Process Management
What is a Process?
A process is basically a program in execution. The execution of a process must progress in a sequential fashion.
A process is defined as an entity which represents the basic unit of work to be implemented in the system.
To put it in simple terms, we write our computer programs in a text file and when we execute this program, it
becomes a process which performs all the tasks mentioned in the program.
When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack,
heap, text and data. The following image shows a simplified layout of a process inside main memory −
1. Stack – The process stack contains the temporary data such as method/function parameters, return address
and local variables.
2. Heap – This is dynamically allocated memory to a process during its run time.
3. Text – This includes the current activity represented by the value of Program Counter and the contents of
the processor's registers.
4. Data – This section contains the global and static variables.
Program
A program is a piece of code which may be a single line or millions of lines. A computer program is usually written
by a computer programmer in a programming language. For example, here is a simple program written in C
programming language −
#include <stdio.h>
int main() {
printf("Hello, World! \n");
return 0;
}
A computer program is a collection of instructions that performs a specific task when executed by a computer. When
we compare a program with a process, we can conclude that a process is a dynamic instance of a computer program.
A part of a computer program that performs a well-defined task is known as an algorithm. A collection of computer
programs, libraries and related data are referred to as a software.
Process Scheduling
CPU Burst – the process is using the CPU to execute machine instructions
I/O Burst – the process is waiting for its I/O operation (writing to the disk) to finish
Process States
A Process Control Block is a data structure maintained by the Operating System for every process. The PCB is
identified by an integer process ID (PID). A PCB keeps all the information needed to keep track of a process.
Program counter: The program counter lets you know the address of the next instruction, which should be
executed for that process.
CPU registers: This component includes accumulators, index and general-purpose registers, and
information of condition code.
CPU scheduling information: This component includes a process priority, pointers for scheduling queues,
and various other scheduling parameters.
Accounting and business information: It includes the amount of CPU and time utilities like real time used,
job or process numbers, etc.
Memory-management information: This information includes the value of the base and limit registers, the
page, or segment tables. This depends on the memory system, which is used by the operating system.
I/O status information: This block includes a list of open files, the list of I/O devices that are allocated to
the process, etc.
The PCB is maintained for a process throughout its lifetime, and is deleted once the process terminates.
Process Operations
Process creation
Process termination
Suspending a process
Resuming a process
Context Switching - the operating system switches the CPU from one process to another
Concurrent Processing
1. Signals – A system message sent from one process to another, not usually used to transfer data but instead
used to remotely command the partnered process.
2. Pipes – Pipe is a communication medium between two or more related or interrelated processes. It can be
either within one process or a communication between the child and the parent processes.
3. Message queuing – Typically implemented by the operating system, they allow multiple processes to read
and write to the message queue without being directly connected to each other.
4. Shared memory – Multiple processes are given access to the same block of memory which creates a
shared buffer for the processes to communicate with each other.
Threads
1. Threads within a certain process share the same main memory space.
2. There is less information associated with each thread.
3. Threads belonging to the same process also share other resources allocated to the process.
4. A process cannot simply control another process unless there is a parent-child relationship between them.
5. Changes made to the parent process will not affect its children.
A race condition occurs when two or more threads can access shared data and they try to change it at the same
time.
Fetched URL: https://www.scribd.com/document/671431181/Module-8-Process-Management
Alternative Proxies: