KEMBAR78
Process 1 | PDF | Process (Computing) | Scheduling (Computing)
0% found this document useful (0 votes)
14 views24 pages

Process 1

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)
14 views24 pages

Process 1

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/ 24

Modes of

operation
Transition to kernel
User mode:
mode:

Mode bit in hardware Occurs on application Enables operating


Computer runs user
indicates current service request or system to handle
applications (e.g., text
mode, with Bit 1 set for system event (e.g., requests or events
document creation).
user mode. interrupt). efficiently.

Note: To switch from kernel mode to user mode, the mode bit should be 1.
Linking & Loading
Process of bringing a
program from secondary
memory to main memory.

Loading:
Performed by a loader program.
Prepares executable files from
the linker for execution by the
computer.
Entire program loaded into
main memory before
execution starts.
Static Loading:

Involves static linking.

Types of loading:
Program loaded into main
memory as needed during
execution.
Dynamic Loading:

Involves dynamic linking.


Linking:

• Process of connecting modules or functions of a


program for seamless execution.
• Collects and organizes code and data into a single
file.
• Involves linking object modules from assembler into
an executable for the loader.

Types of linking:

• Static Linking:
• Done by linkers (link editors) at compile time.
• Results in a standalone executable.
• Requires recompilation for changes in external
programs.
• Dynamic Linking:
• Performed by the operating system at runtime.
• Allows updating and recompiling of individual
shared modules.
• Reduces load time if shared library code is already
in memory.
Process:

• A program in execution.

Example:

• Writing a program in C or C++.


• Compiling it with a compiler to create binary code.
• Both original code and binary code are programs.
• Running the binary code turns it into a process.
Process
Management:
Goals: Benefits:
Essential OS
feature.

Enables multiple
Efficient resource applications to
Responsibilities:
allocation. run
simultaneously.

Manage start, Enhances


Conflict-free
stop, and system
process
scheduling of utilization and
execution.
processes. responsiveness.

Prevent Optimal system


deadlocks. performance.

Facilitate inter-
process
communication.

Synchronize
processes.
Program Process
Program contains a set of instructions designed to complete a
Process is an instance of an executing program.
specific task.

Program is a passive entity as it resides in the secondary Process is a active entity as it is created during execution and loaded
memory. into the main memory.

Program exists at a single place and continues to exist until it is Process exists for a limited span of time as it gets terminated after
deleted. the completion of task.

Program is a static entity. Process is a dynamic entity.

Program does not have any resource requirement, it only Process has a high resource requirement, it needs resources like CPU,
requires memory space for storing the instructions. memory address, I/O during its lifetime.

Program does not have any control block. Process has its own control block called Process Control Block.

In addition to program data, a process also requires additional


Program has two logical components: code and data.
information required for the management and execution.

Many processes may execute a single program. There program code


Program does not change itself. may be the same but program data may be different. these are never
same.

Program contains instructions Process is a sequence of instruction execution.


How Does a Process
Look Like in Memory?

Dynamically
allocated memory
Text Section: Stack: Data Section: Heap Section:
during process run
time.

Includes current Contains temporary Contains global


activity. data. variables.

Includes function
Represented by the
parameters, return
value of the Program
addresses, and local
Counter.
variables.
Process Id: Unique identifier
assigned by the OS.

Characteristics of a Process
Process State: Can be ready,
running, etc.

CPU Registers: Includes the Program


Counter; must be saved and
restored when the process is
swapped in and out.

Accounts Information: Includes CPU


usage, time limits, execution ID, etc.

I/O Status Information: Includes


devices allocated to the process,
open files, etc.

CPU Scheduling Information:


Includes priority (e.g., high priority
for shorter processes in shortest job
first scheduling).
Process Control Block (PCB) also called
as context of the process

Definition:

• Data structure used by the OS to manage and


regulate processes.

Creation:

• A PCB is created with the creation of a process.

Role:

• Crucial for efficient memory and system resource


usage.
CPU Requirement:

• Information in the PCB is required by the


CPU during process execution.

Location:

• PCB of each process resides in the main


memory.

Uniqueness:

• Only one PCB corresponds to each


process.

Structure:

• PCBs of all processes are present in a


linked list.
Terminologies Related
to Process Control Block
• Process State: Stored in PCB; states include “running,” “waiting,” “ready,”
“terminated.”
• Process ID: Unique identifier assigned by the OS to distinguish between processes.
• Program Counter: Stores the last executed instruction during context switch to resume
execution.
• CPU Registers: PCB stores a copy to restore the process state.
• Memory Information: Includes base address and total memory allocated for efficient
memory management.
• Process Scheduling Information: Stores process priority and scheduling algorithm to aid
OS scheduling decisions.
• Accounting Information: Includes CPU time, memory usage, etc., for performance
monitoring.
Operations that are Carried out with the
help of PCB

• Process Scheduling
• Multitasking
• Context Switching
• Resource Sharing

Steps in Context Switching:


• the process state is saved in the CPU
register
• a copy of it is stored in the PCB
• CPU switches to another process then
switches back to that process the CPU
fetches that value from the PCB
• restores the previous state of the
process
Process States in Operating System
1 2 3 4 5 6 7

New State: Ready State: Run State: CPU Blocked or Wait Terminated or Suspend Ready: Suspend Wait or
Process is Process is loaded executes State: Process Completed State: Process in ready Suspend Blocked:
created in into main instructions of waits for I/O, user Process ends, state swapped Process waiting
secondary memory and the chosen input, or access PCB is deleted, out to secondary in secondary
memory, queued for CPU process from the to a locked and allocated storage, can storage due to
awaiting loading execution in the ready queue. resource without resources are return to ready I/O or memory
into main ready queue. needing CPU. released. state when constraints, can
memory by the brought back to return to ready or
OS. main memory. blocked state
upon completion.
Uniprogramming environment of CPU

No. of States: 4 (New, Running, Waiting, Terminate)

Min. no. of states a process go into: 3

Max. no. of states a process go into: 4


The minimum number of
Multiprogramming states through which a
environment of CPU process compulsorily goes
through is 4.

However, if a process also


These states are new state, requires the I/O operation,
ready state, run state and then minimum number of
terminate state. states is 5 and maximum
number of states is 7.

You might also like