0% found this document useful (0 votes)
5 views41 pages

Lecture 3 - Operating Systems Processes

The document discusses the concept of processes in operating systems, highlighting the evolution from single program execution to multitasking environments. It defines a process as a program in execution, managed by the operating system through a Process Control Block (PCB) that contains essential information about the process. Additionally, it outlines the life cycle of a process, including various states such as New, Ready, Running, Waiting, and Terminated, along with the transitions between these states.

Uploaded by

sultanimay599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views41 pages

Lecture 3 - Operating Systems Processes

The document discusses the concept of processes in operating systems, highlighting the evolution from single program execution to multitasking environments. It defines a process as a program in execution, managed by the operating system through a Process Control Block (PCB) that contains essential information about the process. Additionally, it outlines the life cycle of a process, including various states such as New, Ready, Running, Waiting, and Terminated, along with the transitions between these states.

Uploaded by

sultanimay599
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

Operating System –

Processes
Introduction
Early computer systems allowed only one program to be executed at
a time.
This program had complete control of the system and had access to
all the system's resources.

In contrast, current-day computer systems allow multiple programs


to be loaded into memory and executed simultaneously.
This evolution require secure control and more categorization of the
programs; and these needs result in the concept of a Process.

A process is a unit of work in a modern time-sharing system.


Process
A process is a sequential program in execution.
The execution of a process must progress in a sequential fashion.

Definition of process:
“A process is an entity which represents the basic unit of work to be
implemented in the system.”

A process is more than a program.


A Program does nothing unless its instructions are executed by a
CPU. A program in execution is called a process.
To accomplish its task, process needs the computer resources e.g.,
memory, CPU, I/O device etc.
Process and Program
Process is not the same as program. A process is more than a
program code.
A process is an 'active' entity or dynamic entity i.e., a program in
execution as opposed to program which consider to be a 'passive'
entity or static entity.

When this program is sleeping (not executing) it is called a program


and when it is executing becomes a process.
A program exists at single place in space and continues to exist. A
program does not perform the action by itself.
Therefore, the operating system manages all the processes and the
resources in a convenient and efficient way.

The real-life examples of processes in an operating system include


running applications such as web browser, word processor, and
media player.

Each of these applications is a separate process managed by the


operating system.

Each process has its own memory space and resources allocated by
the operating system to ensure efficient multitasking and resource
management.
Kernel
Kernel is the core part of an Operating system; hence it has full
control over everything in the system.

Each operation of hardware and software is managed and controlled


by the kernel.

It acts as a bridge between applications (software) and the CPU,


memory, I/O devices (hardware).

Kernel is the central component of an Operating System.


It is named a kernel because it operates inside the OS, just like a
seed inside a hard shell.
Operating System and Kernel
The Kernel in Deep
The kernel is the initial program loaded up on memory at start-up of
the system after the bootloader.

Once it is loaded, it manages the remaining start-ups.


It manages memory, peripheral, and I/O requests from software.
The execution of programs is the responsibility of this essential
element (kernel) of a computer system.

The kernel is in charge of choosing which of the running


applications should be assigned to the processor or processors at a
time.
It divides the time up for processes to use the processor.
Let us put it in simple words:
Think of a music player you are running in a Windows Operating
System.

When you open an audio file in the music player , the music player
needs hardware like audio devices (speaker) to perform the action of
listening to music.

Here, the music player (software) needs a speaker (hardware) to


perform the command.

Kernel makes the communication between the music player and


audio devices available.
Purposes of the Kernel
The kernel has several important jobs. We can summarize the main
purposes of the kernel as below:
 Determines which process is the next process on the Central
Processing Unit (CPU), when, and how long.
 Monitors how much memory is being used to store what and
where.
 Serves as an interpreter between the hardware and processes.
 Receives requests for service from the processes via system calls.
Difference between a kernel and an Operating System
The operating system and the kernel are both crucial parts of a
computer's function.

The operating system is responsible for managing the computer's


software and hardware resources.

It plays a critical role in managing system resources and providing a


platform for applications to run, while the kernel translates user
commands into machine language.
Difference between a kernel and an Operating System
Sn. Key Operating System Kernel
Operating system is a system Kernel is a part of operating
1 Type
software. system.
Operating system acts as an Kernel acts as an interface
2 Work interface between user and between applications and
hardware. hardware.
A computer needs an An Operating System needs a
3 Basis
Operating System to run. Kernel to run.
Operating System is the first Kernel is the first program to
4 Boot program to load when load when the operating system
computer boots up. loads.
Process Control Block (PCB)
Process Control Block (PCB) is a descriptor (a form) for a process
which contains certain information about a process, which is stored
in memory (protected from user for security reasons).

It is like a personal file that the operating system keeps for every
process i.e., every process has a process control block.

The Operating System consists of Process Control Block (PCB) that


helps control the functioning of processes.

Process Control Block (PCB) is also known as a Process


Description.
Think of the PCB as a special file for a process.

It contains important information about the process that are stored in


a table called Process Table, that helps the operating system manage
and keep track of what the process is doing.

Process Table
When a new process is created, the OS creates a new entry in the
process table for that process.

This entry contains information such as the process's ID, current


state (e.g. running, waiting), and memory management information.
The process table is also used by the OS to manage the scheduling
and execution of processes.
For example, the OS uses the information in the process table to
determine which process should be executed next, and to allocate
resources such as CPU time and memory to each process.

In summary, a process table is a data structure used by an operating


system to store information about running processes, such as process
ID, state, program counter, memory management information, and
other data, to manage their execution, scheduling and allocation of
resources.

The PCB is identified by an integer process ID (PID).


A PCB comprises of the following information:
 Name of the Process.
 Process ID or PID - Identification Number which is given by the
CPU when a Process Request for a Service.
 State of the Process e.g. Ready, Active, Wait.
 Resources allocated to the Process
 Memory which is provided to the Process.
 Scheduling information.
 Input and Output Devices used by the Process.

Each process gets a special name, like “P1,” and has its own file,
which is the PCB.
The process name and their respective PCB is stored in process table
Life Cycle of the
Process
The process life cycle is the sequence of states that a process goes
through during its existence.

A process goes through various stages known as Process States


during its execution.

Instantly after a program is loaded into the RAM, it remains in a


queue called Process Queue.
Process States
As a process executes, it changes state.
The state of a process is defined as the current activity of the
process.
A process goes through a series of five (5) discrete process states
given below:
 New State
 Ready State
 Running State
 Waiting State
 Terminated or Exit
 New State
The process has been created but has not yet been scheduled for
execution.

Once submission is acknowledged, the process is given new status.


At this point, it is not yet ready for execution.
 Ready State
The process is waiting to be assigned to a processor by the
Operating System.

The operating system’s Long-Term Scheduler, also known as the


Job Scheduler decides which processes from the new state are
allowed to enter the ready state based on system resources and
scheduling policies.

When a process is selected, it is moved from new state to ready


state, the activity known as Admitted.
In the ready state, processes are prepared for execution, but they are
not actively running.
 Running State
The process has been assigned to a processor by the Short-Term
Scheduler, also known as the CPU Scheduler or Scheduler
Dispatch which its job is to select a process from the ready state
and allocate the CPU to it and finally the processor executes its
instructions.

A process is said to be running if it has the CPU i.e., process using


the CPU at that instant.
The running process can be interrupted by the hardware or software
cause through a variety of events such as hardware devices
signaling that they need attention or software-generated interrupts.
When an interrupt occurs, the operating system saves the current
state of the CPU, return the process to ready state then transfers
control to a special routine to deal with the specific event.
Once the event has completed its task, the operating system restores
the saved state and allows the interrupted program to resume
execution.

Example:
Suppose you are downloading something, that is a pre-existing
process and during download you open a file or anything that starts
a process.
This new activity will reach OS and signals it to stop the
downloading process for a bit and execute the new interrupting
process.
The real-life Example:
Suppose you are writing an assignment.
Meanwhile, you get an important call on the phone. So, receiving
that call will be on priority for you.

Therefore, you will skip the writing task for a while and attend the
call first.
After finishing the call, you will resume your writing work where
you left off.

The same concept applies when interrupts come in the processor.


 Waiting (or Blocked) State
The process is waiting for an event to occur.

A process moves into the waiting state if it needs to wait for a


resource, such as waiting for user input, data from a slow I/O device
or waiting for a file to become available it enters the waiting state.
Once the event it is waiting for occurs, the process can move back
to the ready state.
 Terminated (Exit) state
The process has finished executing. When a process completes its
execution, it takes transition to the terminated or exit state.
The Process Life Cycle Diagram
Process State
Transitions
Process State Transitions Diagram
Process State Transitions
Following are six (6) possible transitions among above mentioned
five (5) states:

Transition 1 (T1):
It occurs when the process is created.

This state transition is:

Admitted (process-name): New → Ready.


Transition 2 (T2):
It occurs when all other processes have had their share and it is time
for the first process to run again.

This state transition is:

Dispatch (process-name): Ready → Running.


Transition 3 (T3):
It occurs when the scheduler decides that the running process
has run long enough and it is time to let another process have
CPU time.

This state transition is:

Time-Run-Out (process-name): Running → Ready.


Transition 4 (T4):
It occurs when process discovers that it cannot continue. If
running process initiates an I/O operation before its allotted time
expires, the running process voluntarily release the CPU.

This state transition is:

Waiting (process-name): Running → Waiting.


Transition 5 (T5):
It occurs when the external event for which a process was
waiting (such as arrival of input) happens.

This state transition is:

Wakeup (process-name): Waiting → Ready.


Transition 6 (T6):
It occurs when the process has finished execution.

This state transition is:

Exit (process-name): Running → Terminated.

You might also like