0% found this document useful (0 votes)
10 views11 pages

CSC203 Operating Systems Lecture 2A

The document provides an overview of process management in operating systems, defining a process as a program in execution and distinguishing it from a program. It discusses the lifecycle of a process, including various states such as new, ready, running, waiting, and terminated, as well as the architecture of a process in memory. Additionally, it outlines the responsibilities of the operating system in managing processes and resources efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

CSC203 Operating Systems Lecture 2A

The document provides an overview of process management in operating systems, defining a process as a program in execution and distinguishing it from a program. It discusses the lifecycle of a process, including various states such as new, ready, running, waiting, and terminated, as well as the architecture of a process in memory. Additionally, it outlines the responsibilities of the operating system in managing processes and resources efficiently.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Process Management In

OS
Table Of Contents
 Introduction
 What is a Process?
 Process Vs Program
 Process Management
 Layout/Architecture of a Process
 States/Lifecycle of a Process
 Process Hierarchy
 Process Control Block (PCB)
 Attributes of a Process
 Process Operations
 Types of Process
Process Definition
We refer to each CPU activity as a process. Although you might have come across many definitions such as:
 A process is a program in execution which then forms the basis of all computation. A process is a lot more
than a program code It is an instance of a running program. The execution of a process must
progress in a sequential fashion. We can also say that when a program is loaded in the memory it is called a
process. An operating system has the right to create, schedule, and terminate a process.
OR
 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.
OR
 In the Operating System, a Process is something that is currently under execution. So, an active program can
be called a Process. For example, when you want to search something on web then you start a browser. So,
this can be process. Another example of process can be starting your music player to listen to some cool
music of your choice.
Program vs Process:

 A process is a program in execution. For example, when we write a program in C or C++ and compile it, the
compiler creates binary code. The original code and binary code are both programs. When we actually run the
binary code, it becomes a process.
 A process is an ‘active’ entity instead of a program, which is considered a ‘passive’ entity. A single program
can create many processes when run multiple times; for example, when we open a .exe or binary file multiple
times, multiple instances begin (multiple processes are created).
.

Difference between a Process & a Program

Process Program

A Program is basically a collection of instructions


The process is basically an instance of the
that mainly performs a specific task when executed
computer program that is being executed.
by the computer.

A process has a shorter lifetime. A Program has a longer lifetime.

A Process requires resources such as memory, A Program is stored by hard-disk and does not
CPU, Input-Output devices. require any resources.

A process has a dynamic instance of code and


A Program has static code and static data.
data

Basically, a process is the running On the other hand, the program is the executable
instance of the code. code.
Process Management in OS

 A Program does nothing unless its instructions are executed by a CPU. A program in execution is called a
process. In order to accomplish its task, process needs the computer resources .There may exist more than one
process in the system which may require the same resource at the same time. Therefore, the operating system
has to manage all the processes and the resources in a convenient and efficient way.
 Some resources may need to be executed by one process at one time to maintain the consistency otherwise the
system can become inconsistent and deadlock may occur.
 The operating system is responsible for the following activities in connection with Process Management
• Scheduling processes and threads on the CPUs.
• Creating and deleting both user and system processes.
• Suspending and resuming processes.
• Providing mechanisms for process synchronization.
• Providing mechanisms for process communication.
Layout/Architecture of a Process inside Main
Memory
 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.
• Stack: Temporary data like method or function parameters, return address,
and local variables are stored in the process stack.
• Heap: This is the memory that is dynamically allocated to a process
during its execution.
• Text: This includes the current activity represented by the value of
Program Counter and the contents of the processor's registers.
• Data: The global as well as static variables are included in this section.
Layout/Architecture of a Process inside
Main Memory
Note:
The start and heap sections at opposite end of the process’s free space and grow towards
each other. When they meet a stack overflow will occur or a call to new memory allocation
will fail due to insufficient memory available in the heap section.
States/Life cycle of a Process
 States of a Process
During the execution of a process, it undergoes a number of states. So, in this section of the blog, we will learn
various states of a process during its lifecycle.
• New State: This is the state when the process is just created. It is the first state of a process.
• Ready State: After the creation of the process, when the process is ready for its execution then it goes in the
ready state. In a ready state, the process is ready for its execution by the CPU but it is waiting for its turn to
come. There can be more than one process in the ready state.
• Ready Suspended State: There can be more than one process in the ready state but due to memory
constraint, if the memory is full then some process from the ready state gets placed in the ready suspended
state.
• Running State: Amongst the process present in the ready state, the CPU chooses one process amongst them
by using some CPU scheduling algorithm. The process will now be executed by the CPU and it is in the
running state.
States/Life cycle of a Process
• Waiting or Blocked State: During the execution of the process, the
process might require some I/O operation like writing on file or some
more priority process might come. In these situations, the running
process will have to go into the waiting or blocked state and the other
process will come for its execution. So, the process is waiting for
something in the waiting state.
• Waiting Suspended State: When the waiting queue of the system
becomes full then some of the processes will be sent to the waiting
suspended state.
• Terminated State: After the complete execution of the process, the
process comes into the terminated state and the information related to
this process is deleted.
States/Life cycle of a Process
 Lifecycle of a Process
In the above image, you can see that when a process is created then it
goes into the new state. After the new state, it goes into the ready state.
If the ready queue is full, then the process will be shifted to the ready
suspended state. From the ready sate, the CPU will choose the process
and the process will be executed by the CPU and will be in the running
state. During the execution of the process, the process may need some
I/O operation to perform. So, it has to go into the waiting state and if
the waiting state is full then it will be sent to the waiting suspended
state. From the waiting state, the process can go to the ready state after
performing I/O operations. From the waiting suspended state, the
process can go to waiting or ready suspended state. At last, after the
complete execution of the process, the process will go to the
terminated state and the information of the process will be deleted.
This is the whole life cycle of a process.

You might also like