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

Main Os Notes

An operating system (OS) serves as an interface between computer hardware and users, managing resources and facilitating program execution. It encompasses various types, including batch, multi-programming, multitasking, and real-time systems, each with distinct advantages and disadvantages. Key components of an OS include the kernel and shell, which handle process management, memory allocation, and device communication.

Uploaded by

damamegha3006
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)
5 views70 pages

Main Os Notes

An operating system (OS) serves as an interface between computer hardware and users, managing resources and facilitating program execution. It encompasses various types, including batch, multi-programming, multitasking, and real-time systems, each with distinct advantages and disadvantages. Key components of an OS include the kernel and shell, which handle process management, memory allocation, and device communication.

Uploaded by

damamegha3006
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

OPERATING SYSTEM

Operating System

• An operating system acts as an Interface between computer hardware and


the user.
• The purpose of an operating system is to provide an environment in which
a user can execute programs conveniently and efficiently
• An OS is a software that manages and handles hardware and software
resources of a computing device.
• Responsible for managing and controlling all the activities and sharing of
computer resources among different running applications.
• Responsible for all the basic functions like processor management, memory
management, file management, etc.
• Examples are Linux, Unix, Windows 11, MS DOS, Android, macOS and iOS.
Where Operating System lies?
Operating System and User Interaction

An operating system provides an interface for user interaction, typically


through:
• Command-Line Interface (CLI), (e.g., Bash, PowerShell)
• Graphical User Interface (GUI), (e.g., Windows desktop, macOS
Finder)
Goals of Operating System - Primary Goals
• User Convenience: It should be easy to use, providing a user-friendly
interface and making it simple to interact with the system.
• Program Execution: It facilitates the execution of user programs,
providing the necessary environment and services for them to run.
• Resource Management: Manages and allocates the computer's
resources, including the CPU, memory, disk storage and input/output
devices, to ensure fair utilization.
• Security: The OS protects the system and user data from unauthorized
access, ensuring confidentiality, integrity and availability of information.
Goals of Operating System - Secondary Goals

• Efficient Resource Utilization: It should aim to maximize the


performance and utilization of computer resources like CPU,
Memory and I/O devices, ensuring that the system runs smoothly and
efficiently.
• Reliability:
• It should be robust and reliable,
• Able to handle errors and exceptions gracefully
• Ensuring that the system continues to operate smoothly
• It should be modular in design and easy to debug.
Components of an Operating System
There are two basic components of an Operating System.
1. Shell
• The outermost layer of the Operating System and handles user
interaction.
• It interprets input for the OS and handles the output from the OS.
2. Kernel
• Core component of the operating system
• It is the primary interface between the Operating system and Hardware.
List of Common Operating Systems
There are multiple types of operating systems each having its own unique
features:
• Windows OS : Developed by Microsoft. Used in personal computing, business
environment, gaming.
• macOS : Developed by Apple. Used for creative industries (design, video
editing, music production), Personal computing and Professional
environments.
• Linux : Developed by Linus Torvalds and maintained by the open-source
community (Linux Foundation, Red Hat, Canonical, etc.). Used in servers and
data centers, development and programming, Personal computing for tech
enthusiasts.
• Unix : Developed originally AT&T Bell Labs, various commercial and open-
source versions available. Used in servers and workstations, Development
environments, Research and academic settings
Applications of Operating System

• Platform for Application Programs: It provides a platform, on top of which,


other programs, called application programs can run.
• Managing Input-Output Unit: It also allows the computer to manage its own
resources such as memory, monitor, keyboard, printer, etc. Management of
these resources is required for effective and fair utilization.
• Multitasking: It manages memory and allows multiple programs to run in
their own space and even communicate with each other through shared
memory.
• Manages Memory and Files: It manages the computer’s main memory and
secondary storage. Additionally, it allows and deallocates memory to all tasks
and applications.
• Provides Security: It helps to maintain the system and applications safe
through the authorization process. Thus, the OS provides security to the
system.
Applications of Operating System

• Platform for Application Programs: It provides a platform, on top of which,


other programs, called application programs can run.
• Managing Input-Output Unit: It also allows the computer to manage its own
resources such as memory, monitor, keyboard, printer, etc. Management of
these resources is required for effective and fair utilization.
• Multitasking: It manages memory and allows multiple programs to run in
their own space and even communicate with each other through shared
memory.
• Manages Memory and Files: It manages the computer’s main memory and
secondary storage. Additionally, it allows and deallocates memory to all tasks
and applications.
• Provides Security: It helps to maintain the system and applications safe
through the authorization process. Thus, the OS provides security to the
system.
Applications of Operating System

• Platform for Application Programs: It provides a platform, on top of which,


other programs, called application programs can run.
• Managing Input-Output Unit: It also allows the computer to manage its own
resources such as memory, monitor, keyboard, printer, etc. Management of
these resources is required for effective and fair utilization.
• Multitasking: It manages memory and allows multiple programs to run in
their own space and even communicate with each other through shared
memory.
• Manages Memory and Files: It manages the computer’s main memory and
secondary storage. Additionally, it allows and deallocates memory to all tasks
and applications.
• Provides Security: It helps to maintain the system and applications safe
through the authorization process. Thus, the OS provides security to the
system.
Types of Operating Systems
• Different types of OS serve different needs; some handle one task at a
time, while others manage multiple users or real-time processes.
1. Batch Operating System
• A Batch Operating System is designed to handle large groups of similar jobs
efficiently.
• It does not interact with the computer directly but instead processes jobs that
are grouped by an operator.
• These jobs are queued and executed one after the other, without user
interaction during the process.

Examples:
•Payroll Systems
•Bank Statements

Processes groups of similar jobs automatically in batches


without user interaction.
Advantages of Batch Operating System
• Minimal Idle Time: The system minimizes idle time by processing jobs in a
continuous sequence without human intervention.
• Handling Repetitive Tasks: Ideal for managing large, repetitive tasks, such as
payroll and billing, with minimal effort.
• Improved Throughput: Batch systems can handle high volumes of jobs at
once, impro
Disadvantages of Batch Operating System
• Inefficient CPU Utilization: When a job is waiting for input/output (I/O), the
CPU remains idle, leading to poor utilization of resources.
• Increased Response Time: The time between job submission and output can
be high as all jobs are processed sequentially.
• Lack of Real-Time Feedback: Users cannot interact with the system in real-
time, making it less suitable for interactive tasks.
2. Multi-Programming Operating System
• In a Multi-Programming Operating System, multiple programs run in memory
at the same time.
• The CPU switches between programs, utilizing its resources more effectively
and improving overall system performance.

Examples:
•Banking systems
•Railway servers
•Billing machines

Runs multiple programs in memory at the same time to


maximize CPU usage.
Advantages
• Better CPU Utilization: CPU stays busy by switching to another job during I/O
wait.
• Improved Throughput: Multiple jobs run concurrently, increasing work done
per unit time.
• Efficient Resource Use: CPU, memory, and I/O devices are shared effectively
among processes.
Disadvantages
• Complex Design: Requires advanced memory management and CPU
scheduling.
• Security Issues: More programs in memory increase chances of unauthorized
access.
• High Memory Requirement: Needs larger RAM to run multiple programs
together.
3. Multi-tasking/Time-sharing Operating systems
• Multitasking OS is a type of multiprogramming system where each process
runs in a round-robin manner.
• Every task gets a fixed time slice called a quantum. After the quantum ends,
the OS switches to the next task, allowing multiple tasks—whether from one
user or many—to run smoothly on a single system.

Examples:
• IBM VM/CMS
• TSO (Time Sharing Option
• Windows Terminal Services

Allows multiple tasks to run by giving each a small time


slice for smooth, shared system use.
Advantages
• Equal CPU Access: Each task gets a fair share of CPU time.
• Reduced Software Duplication: Many users can run the same software
without needing separate copies.
• Low CPU Idle Time: Efficient scheduling keeps the CPU busy.
Disadvantages
• Lower Reliability: System failures affect all users.
• Security Concerns: Multiple users increase risks to data integrity and privacy.
• Communication Issues: Data sharing between users can cause conflicts.
4. Multi-Processing Operating System
• A Multi-Processing Operating System is a type of Operating System in which
more than one CPU is used for the execution of resources.
• It betters the throughput of the System.

Examples:
• UNIX
• Linux (Ubuntu, Red Hat, Debian)
• macOS

Uses two or more CPUs simultaneously to increase speed


and reliability.
Advantages
• Faster Processing: Multiple CPUs work simultaneously, increasing overall
system speed.
• High Reliability: If one processor fails, others can continue working (fault
tolerance).
• Supports Heavy Tasks: Ideal for computation-intensive applications like
scientific or industrial tasks.
Disadvantages
• High Cost: Multiple processors and complex hardware increase system cost.
• Complex Design: Requires advanced OS support for communication and task
distribution.
• Not Always Efficient: Poor task distribution can lead to idle processors and
wasted resources.
5. Distributed Operating System
• Distributed operating systems connects multiple independent computers
through a shared communication network.
• Each system has its own CPU and memory but works together as a single unit.
• The main benefit is remote access, allowing users to use files and software
stored on other connected systems.

Examples:
• LOCUS
• MICROS
• Amoeba

Connects multiple independent computers to function as


a single coordinated system.
Advantages
• Independent Systems: Failure of one machine does not affect others.
• Easily Scalable: New systems can be added to the network easily.
• Lower Processing Delays: Tasks are handled faster across multiple machines.
Disadvantages
• Network Dependency: If the main network fails, communication stops.
• Lack of Standardization: No well-defined language or model for building such
systems.
• High Cost & Complexity: Hardware is expensive, and the software is complex
and not widely understood.
6. Network Operating System
• A Network Operating System (NOS) runs on a server and manages data, users, security,
applications, and other network functions.
• It allows shared access to files, printers, and resources within a small private network.
• Users can see the configuration and connections of other users, which is why these systems
are considered tightly coupled systems.

Examples:
• Microsoft Windows Server 2003
• UNIX, Linux
• Mac OS X

Manages and supports users, data, and security across


connected computers within a network.
Advantages
• Centralized and Stable Servers: Provide reliable management of resources.
• Easy Upgrades: New hardware and technologies can be added without
difficulty.
• Remote Access: Users can access the server from different locations and
devices.
Disadvantages
• High Server Cost: Setting up and maintaining servers is expensive.
• Dependency on Server: Most operations rely on a central server.
• Regular Maintenance Needed: Frequent updates and technical support are
required.
7. Real-Time Operating System
• These types of OSs serve real-time systems.
• The time interval required to process and respond to inputs is very small.
• This time interval is called response time.
• Real-time systems are used when there are time requirements that are very strict like
missile systems, air traffic control systems, robots, etc.
Types of Real-Time Operating Systems
• Hard Real-Time Operating System: Used where strict timing is essential and any delay is
unacceptable, such as airbags or automatic parachutes. These systems avoid virtual
memory to ensure immediate response.
• Soft Real-Time Operating System: Used where timing is important but minor delays are
acceptable. These systems aim to give quick and predictable responses but do not require
perfect accuracy. They are commonly used in multimedia applications, gaming, video
streaming, and other interactive tasks.
Advantages
• Maximum Consumption: Maximum utilization of devices and systems, thus
more output from all the resources.
• Error-Free: These types of systems are error-free.
• Memory Allocation: Memory allocation is best managed in these types of
systems.
Disadvantages
• Limited Tasks: Very few tasks run at the same time and their concentration is
very less on a few applications to avoid errors.
• Complex Algorithms: The algorithms are very complex and difficult for the
designer to write.
• Thread Priority: It is not good to set thread priority, as these systems are
much less prone to switching tasks.
8. Mobile Operating Systems
• Mobile operating systems are designed specifically for mobile devices such as smartphones
and tablets.
• Examples of such operating systems are Android and iOS.
• These operating systems manage the hardware and software resources of the device,
providing a platform for running applications and ensuring a seamless user experience.
Advantages
• User-Friendly Interfaces: Mobile operating systems are designed to be intuitive and
easy to use, making them accessible to a wide range of users.
• Extensive App Ecosystems: The availability of a vast number of applications allows
users to customize their devices to meet their specific needs.
• Connectivity Options: Mobile operating systems support multiple connectivity
options, enabling users to stay connected wherever they go.
Disadvantages
• Battery Life Constraints: Despite advancements in power management, battery life
remains a challenge for mobile devices, especially with heavy usage.
• Security Risks: Mobile devices are susceptible to various security threats, such as
malware and phishing attacks, which can compromise user data.
• Fragmentation: In the case of Android, the wide range of devices and
customizations can lead to fragmentation, making it difficult for developers to
ensure compatibility across all devices.
Kernel in Operating System
• A kernel is the core part of an operating system. It acts as a
bridge between software applications and the hardware of a
computer.
• Facilitates communication between hardware and user
applications.
• The kernel manages system resources, such as the CPU,
memory and devices, ensuring everything works together
smoothly and efficiently.
• It handles tasks like running programs, accessing files and
connecting to devices like printers and keyboards.
• An Operating System includes the kernel as its core, but also
provides a user interface, file system management,
network services and various utility applications that allow
users to interact with the system
• Ensures efficient and secure multitasking.
• Manages system stability and prevents unauthorized
resource access.
Types of Kernel
• Monolithic kernel: all OS services run in kernel space → fast, but less fault-
isolation. Examples are Unix, Linux, Open VMS, XTS-400 etc.
• Microkernel: minimal kernel functionality; most services moved to user space →
better reliability, but more overhead. Examples are Minix 3 and Mach (true
microkernel versions like Mach 3.0),
• Hybrid kernel: mixes monolithic + microkernel ideas; some services in kernel for
speed, others isolated for safety. Examples are Windows NT family (Windows
2000, XP, Vista, 7, 8, 10 etc.), macOS / XNU, ReactOS and Haiku OS
• Nanokernel: extremely minimal kernel, providing only basic hardware
abstraction; everything else outside. Examples are Nemesis and MIT Exokernel
projects like XOK, Aegis
• Exokernel: separates protection vs. management; gives apps direct control over
hardware abstractions so apps decide what abstractions to build.
Functions of Kernel
• The kernel is responsible for various critical functions that ensure the smooth
operation of the computer system. These functions include:
Functions of Kernel
• Process Management : Scheduling and execution of processes.
• Memory Management : Allocation and deallocation of memory space, managing
virtual memory, handling memory protection and sharing.
• Device Management : Managing input/output devices, providing a unified
interface for hardware devices and handling device driver communication.
• File System Management : Managing file operations and providing a file system
interface to applications.
• Resource Management : Managing system resources (CPU time, disk space,
network bandwidth). Mainly allocating and deallocating resources as needed.
• Security and Access Control : Enforcing access control policies like user
permissions and authentication.
• Inter-Process Communication : Facilitating communication between processes by
providing mechanisms like message passing and shared memory.
OPERATING SYSTEM STRUCTURE
Operating Systems Structures
• An OS structure depends on component organization and interaction.
• Acts as a blueprint that guides OS design.
• Breaking the OS into smaller parts simplifies development.
• Structure defines how components are integrated into the kernel.
1. Simple Structure

• No well-defined structure; small and limited.


• Interfaces and functionality levels are not separated.
• MS-DOS is an example of this structure.
• Applications can directly access basic I/O routines.
• Their interfaces and functional levels are not clearly
separated, which makes them less reliable.
• Because of this lack of separation, a failure in any user
program can cause the entire system to crash.
2. Layered Structure
• OS is divided into multiple layers (hardware at
bottom, UI at top).
• Each layer uses the functions of the layer below it.
• Easier debugging because errors are isolated to
specific layers.
• Adds overhead due to data passing through many
layers.
• Requires careful planning; layers can only use lower
layers.
• UNIX is an example of a layered structure.
3. Modular Structure

• Kernel contains only core components.


• Extra services are added as dynamically
loadable modules.
• More flexible than layered structure;
modules can call any other module.
• Used in systems like Solaris.
4. Virtual Machines (VMs)

• Each VM behaves like a separate, independent


machine.
• VirtualBox is a common example of virtualization.
• CPU scheduling and virtual memory give each VM
dedicated-like resources.
• The fundamental issue with the virtual machine
technique is disk-system limitations.
• If a host machine has only three physical disks but
needs to support seven VMs, it cannot assign one
disk per VM. Instead, the hypervisor creates
virtual disks.
5. Monolithic Structure

• A monolithic structure is an OS
architecture in which the entire system is
built as one large kernel.
• All major services—such as process
management, memory management, file
systems and device drivers—run
together in a single code base.
• This design places all core functionality
inside one unified kernel.
6. Micro-Kernel Structure
• Non-essential services run in user space, leaving a small core kernel.
• New services can be added without changing the kernel.
• More secure and reliable because failures don’t crash the whole OS.
• macOS uses microkernel ideas within its hybrid XNU kernel.
7. Hybrid-Kernel Structure
• A hybrid-kernel structure combines the features of both monolithic and microkernel
architectures.
• It blends the speed and performance of monolithic kernels with the modularity and
stability of microkernels.
• This approach offers a more flexible and efficient design than either structure alone.
Overall
• Combines monolithic and microkernel concepts.
• Provides monolithic-level speed and performance.
• Offers microkernel-style modularity and stability.
• Results in a more flexible and efficient OS design.
8. Exo-Kernel Structure
• Exo-kernel is an OS architecture developed at MIT that gives applications direct control
over hardware resources by separating resource protection from resource management.
• Its design avoids imposing OS-level abstractions, allowing applications to customize
resources as needed. Because of this minimal approach, exokernels are small and offer
developers greater flexibility.
In general
• Provides application-level control of hardware resources.
• Separates protection from resource management.
• Avoids enforcing OS abstractions to allow customization.
• Small, minimal design that offers greater developer freedom.
System Call
System Call
• A system call is an interface between a program
running in user space and the operating system.
• Application programs use system calls to request
services and functionalities from the OS's kernel.
• This mechanism allows the program to call a
service, such as reading from a file, without
directly accessing system resources.
• Example:
• Opening a file in C (fopen) internally uses system
calls like open().
• Running a program in Linux uses fork() and exec()
system calls.
• Printing on screen uses the write() system call.
How do System Calls Work?
1. System Call Request. The application requests a system call
by invoking its corresponding function. For instance, the
program might use the read() function to read data from a
file.
2. Context Switch to Kernel Space. A software interrupt, or
special instruction, is used to trigger a context switch and
transition from user mode to kernel mode.
3. System Call Identified. The system uses an index to identify
the system call and address the corresponding kernel function.
[Link] Function Executed. The kernel function corresponding
to the system call is executed. For example, reading data from
a file.
5. System Prepares Return Values. After the kernel function
completes its operation, any return values or results are
prepared for the user application.
6. Context Switch to User Space. The execution context is
switched back from kernel mode to user mode.
7. Resume Application. The application resumes its execution
from where it left off, now with the results or effects of the
system call.
Types of System Calls
• Services provided by an OS are typically
related to any kind of operation that a user
program can perform like creation,
termination, forking, moving,
communication, etc.
• Similar types of operations are grouped
into one single system call category.
• System calls are classified into the
following categories:
Types of System Calls
• Process Control: to create and oversee processes. Examples include the functions fork(),
exec(), wait(), and exit().
• Device Management: Controls hardware components such as network interfaces, printers,
and scanners. Examples are the functions ioctl(), read(), write(), and open().
• Inter-process communication (IPC): These system calls let processes executing on the
same or other systems interact. Examples are socket(), bind(), listen(), accept(), connect(),
sendto(), and recvfrom().
• File management: One can create, open, read, write, close, and destroy files using these
system functions. Examples include the functions open(), read(), write(), close(), and
unlink().
• Information management: Between the operating system and computer programs, these
system calls to manage and send data. Examples are time(), getpid(), getuid(), and
getgid().
Examples of System Calls
Examples of System Calls
Examples of System Calls
Process Management
Introduction of Process Management
• Process : A process is basically a program in
execution. The execution of a process must
progress in a sequential fashion.
• Definition: A process is defined as an entity which
represents the basic unit of work to be
implemented in the system
• 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 −
Process Management

[Link]. Component & Description


Stack: The process Stack contains the temporary data such as
1
method/function parameters, return address and local variables.
Heap: This is dynamically allocated memory to a process during its run
2
time.
Text: This includes the current activity represented by the value of Program
3
Counter and the contents of the processor's registers.
4 Data: This section contains the global and static variables.
Process Life Cycle
• When a process executes, it passes through different states.
• These stages may differ in different operating systems, and the names of these states
are also not standardized.
• In general, a process can have one of the following five states at a time.
Process Life Cycle
[Link]. State & Description

1 Start :This is the initial state when a process is first started/created.

Ready: The process is waiting to be assigned to a processor. Ready processes are waiting to have the
processor allocated to them by the operating system so that they can run. Process may come into this
2
state after Start state or while running it by but interrupted by the scheduler to assign CPU to some other
process.

Running: Once the process has been assigned to a processor by the OS scheduler, the process state is set
3
to running and the processor executes its instructions.

Waiting: Process moves into the waiting state if it needs to wait for a resource, such as waiting for user
4
input, or waiting for a file to become available.

Terminated or Exit: Once the process finishes its execution, or it is terminated by the operating system, it
5
is moved to the terminated state where it waits to be removed from main memory.
Process Scheduling
Definition
• The process scheduling is the activity of the process manager that handles the removal of the
running process from the CPU and the selection of another process on the basis of a
particular strategy.
Categories of Scheduling
There are two categories of scheduling:
1. Non-preemptive:
• Here the resource can't be taken from a process until the process completes execution.
• The switching of resources occurs when the running process terminates and moves to a
waiting state.
2. Preemptive:
• The OS allocates the resources to a process for a fixed amount of time.
• During resource allocation, the process switches from running state to ready state or from
waiting state to ready state.
• This switching occurs as the CPU may give priority to other processes and replace the process
with higher priority with the running process.
Process Scheduling Queues
The Operating System maintains the following important process scheduling queues −
• Job queue − This queue keeps all the processes in the system.
• Ready queue − This queue keeps a set of all processes residing in main memory, ready
and waiting to execute. A new process is always put in this queue.
• Device queues − The processes which are blocked due to unavailability of an I/O
device constitute this queue.
Process Schedulers
• Schedulers are special system software components responsible for deciding which
process should be executed, when, and for how long.
Based on their role and frequency of execution, schedulers are classified into three
types −
• Long-Term Scheduler
• Short-Term Scheduler
• Medium-Term Scheduler
1. Long-Term Scheduler (Job Scheduler)
• The Long-Term Scheduler, also known as the Job Scheduler, determines which programs
are admitted into the system for execution. It selects processes from the job queue
(secondary storage) and loads them into main memory so they can compete for CPU
scheduling.
Functions
➢ Selects processes from the new state Key Points
➢ Loads selected processes into ready state •If the degree of multiprogramming is stable,
➢ Controls the degree of multiprogramming (number Process arrival rate = Process completion rate
of processes in memory) •Invoked less frequently
Primary Objective •Some systems (especially time-sharing operating
The main objective of the long-term scheduler is to systems) may have no long-term scheduler or only a
maintain a balanced mix of processes, such as: minimal one
•CPU-bound processes (require more CPU time) •It is used when a process moves from new → ready
•I/O-bound processes (require more I/O operations) state
2. Short-Term Scheduler (CPU Scheduler)
• The Short-Term Scheduler, also called the CPU Scheduler, decides which ready process
should be allocated the CPU next.

Functions
➢ Selects a process from the ready queue
➢ Allocates the CPU to that process
➢ Causes a state change from ready → running Key Points
Primary Objective • Invoked very frequently (milliseconds)
The main goal of the short-term scheduler is to • Must be extremely fast
maximize system performance, based on criteria such • Works closely with the dispatcher
• Plays a major role in multitasking and time-sharing
as:
systems
▪ CPU utilization
▪ Throughput
▪ Response time
▪ Waiting time
3. Medium-Term Scheduler
• The Medium-Term Scheduler is associated with swapping, which involves temporarily
removing processes from main memory.

Functions
➢ Removes processes from memory (swap out)
➢ Reintroduces processes back into memory (swap in)
➢ Reduces the degree of multiprogramming Benefits
➢ Manages suspended processes • Improves memory utilization
Why Medium-Term Scheduling is Needed • Enhances process mix
• A running process may request I/O and become • Prevents memory congestion
blocked
• Suspended processes cannot make progress
• To free memory for other processes, such processes
are moved to secondary storage
This operation is called swapping, and the process is said
to be: Swapped out or rolled out
Process Control Block (PCB)
• The architecture of a PCB is completely dependent on Operating System and may contain different information in
different operating systems. Here is a simplified diagram of a PCB −
Process Control Block (PCB)
• A Process Control Block is identified by an integer process ID (PID).
• A PCB keeps all the information needed to keep track of a process as listed below in the table −
S.N. Information & Description
1 Process State: The current state of the process i.e., whether it is ready, running, waiting, or whatever.
2 Process privileges: This is required to allow/disallow access to system resources.
3 Process ID: Unique identification for each of the process in the operating system.
4 Pointer: A pointer to parent process.
Program Counter: Program Counter is a pointer to the address of the next instruction to be executed for
5
this process.
6 CPU registers: Various CPU registers where process need to be stored for execution for running state.
CPU Scheduling Information: Process priority and other scheduling information which is required to
7
schedule the process.
Memory management information: This includes the information of page table, memory limits,
8
Segment table depending on memory used by the operating system.
Accounting information: This includes the amount of CPU used for process execution, time limits,
9
execution ID etc.
10 IO status information: This includes a list of I/O devices allocated to the process.
Process Management Tasks That Utilize PCB
Context Switching
• During context switching, the process state of the executing process is saved in the CPU register and a copy
of it is stored in the corresponding PCB.
• The state of process which is selected for execution next is fetched from its PCB so that it can execute.
Process Scheduling
• The operating system uses the contents of PCB such as process priority, process state, and resources utilized
to schedule the processes from the ready queue.
• By assessing the priority and other related information, the scheduler determines the sequence of process
execution.
Multitasking
• The operating system can multitask and run various processes simultaneously with the help of information
stored in PCBs like resource allocation, process scheduling, and process synchronization.
Resources Sharing
• The information stored in the PCB includes the resources allocated to a process, like open files, shared
variables, common tables and memory space.
• When a new process requests resources, the OS searches the allocated processes in the PCBs, checks
whether they are shareable or not and allocates the resources accordingly.
• Thus PCBs play an important role in resource sharing.
What is a Process in OS?
• A process is a program in execution that undergoes a number of states in its lifetime. In each of
these states, a process undergoes certain operations that enable the process to execute into
completion.

States of a Process
1. New − Process is created.
2. Ready − Process is ready with all its resource
allocation and waiting for CPU allocation.
3. Running − Instructions in the process are
being executed in CPU.
4. Waiting − Process is in waiting for completion
of an input output or any other event.
5. Terminated − Process finishes execution and
exits the system.
Different Process Operations in Operating System

• The operations on a process occur when the process is in a particular state or when
the process makes a transition from one state to another.
• There are mainly four operations on a process −
➢ Process Creation
➢ Process Dispatch
➢ Process Pre-emption
➢ Process Blocking
➢ Process Termination
Different Process Operations in Operating System
In an Operating System, a process is a program in execution. The OS performs several key operations to
manage processes efficiently:
1. Process Creation : A new process is created when a program is executed. The OS allocates memory,
assigns a Process ID (PID), and initializes required resources. Parent processes can create child
processes.
2. Process Scheduling: The OS decides which process gets the CPU and for how long. Scheduling ensures
fair CPU utilization and better system performance.
3. Process Execution: The process moves from the ready state to the running state and starts executing
instructions on the CPU.
4. Process Waiting (Blocking): A running process may need to wait for an event such as I/O completion.
During this time, it moves to the waiting state.
5. Process Suspension and Resumption: A process can be temporarily suspended (paused) and later
resumed, usually to manage memory or system load.
6. Process Termination: A process ends after completing execution or due to errors. The OS releases all
resources allocated to it.
In short: Process operations help the OS create, control, execute, and terminate programs smoothly,
enabling multitasking and efficient resource utilization.
Inter Process Communication (IPC)

• Inter process Communication (IPC) is a mechanism which allows the exchange of


data between processes. It enables resource and data sharing between the
processes without interference. This communication involves a process letting
another process know that some event has occurred or they has been data transfer
between two or more processes.
[Link]
systems/types-of-operating-systems/

You might also like