0% found this document useful (0 votes)
2 views

Operating System

An operating system (OS) acts as an interface between user applications and hardware, managing resources and simplifying application development. It has various goals such as user convenience and efficiency, with different types including batch processing, multitasking, and real-time systems. Process management within an OS involves executing programs, managing their states, and scheduling them effectively to optimize CPU utilization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Operating System

An operating system (OS) acts as an interface between user applications and hardware, managing resources and simplifying application development. It has various goals such as user convenience and efficiency, with different types including batch processing, multitasking, and real-time systems. Process management within an OS involves executing programs, managing their states, and scheduling them effectively to optimize CPU utilization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Operating System

Unit 1
What is OS?
• OS stands for operating system
Definition
• It act as interface between user applications
and hardware.
• System program that plays the role of
resource manager.
• Set of utilities to simplify application
development/execution.
• Act like government.
• Examples of Operating Systems are Windows,
Linux, Mac OS, etc.
• Hardware – CPU, Memory , I/O devices.
Goals of OS
• User Convenience- how easily user can interact with hardware
• Efficiency – how good it can utilize resources
• Generally, it is evaluated in terms of throughput.
• Throughput refers to number of tasks executed per second.
• For window OS- primary goal is user convenience while is secondary goal
• In Linux OS- efficiency – primary goal, user convenience – secondary goal
• Other goals –
• reliability,
• portability,
• robustness,
• scalability
Parts of OS
• Generally two parts
• Shell
• Kernel
• OS consists of different modules(system program
• Kernel consists of functions that defines the function of different
modules of OS.
• Right click on file folder empty place has different menus-
(different modules defined)
• Double click, right click has different function defined and are
stored in kernel.
• To reach/interact with kernel we use shell.
• Generally, two ways of shell – GUI or CLI command line.
• Each OS has different kernel
• Different kernel has multiple Shell
• For e.g. windows support both GUI and CLI
• While linux OS support generally CLI
Program Mode of operation
• User Mode
• Kernel Mode
System Call ▪ In user mode, program under execution doesn’t have
• System call is the way by which user whole access to system resource.
program interact with OS. ▪ To define which mode, a mode bit is used.
• Double click – shell -> system call -> ▪ Mode bit – 1 : user mode, 0: kernel mode.
kernel. ▪ If allow every access , virus creation is easily
possible.
• Shell scripting – different commands ▪ In kernel mode , program under execution can
and what they do.
access all resources.
• File- open(), read(), close(), write(), ▪ Also known as privileged mode.
create file,
• Process control- load, execute,
abort, fork, wait =, signal, etc.
• Information- get pid, attributes,
system time and date.
• Device related- read, write, ioctl.
Functions of OS
• Resource Management- mapping hardware resource to multiple applications
running simultaneous.
• Process Management- how to run multiple process on system hardware. (CPU
scheduling)
• Storage Management- how process are stored in secondary memory( File system
(NTFS FAT32)
• Memory Management- How to stored process and bring which process in RAM ( as it
is limited). ( Multi programming/tasking)
• Security and Privacy- ( Authentication / password, user and admin mode, one
program cannot interfere with other program resources).
• Accounting – Task manager
Types of OS
• Batch Processing OS
• Multiprogramming
• Multitasking
• Multiprocessing
• Real Time OS
• Embedded
• Distributed OS
• Generally 3 components- CPU , Memory, I/O.
• OS resides in Main memory (RAM).
Batch Processing
• This type of operating system does not interact with
the computer directly.
• There is an operator which takes similar jobs having
the same requirement and groups them into batches.
• It is the responsibility of the operator to sort jobs with
similar needs
• Only one program reside in main memory , low CPU
utilization
Advantages of Batch Operating System
• Job completion time is known.
• Multiple users can share the batch systems.
Disadvantages of Batch Operating System
• The computer operators should be well known with
batch systems.
• Batch systems are hard to debug.
• The other jobs will have to wait for an unknown time if
any job fails.
Multiprogramming OS
• To increase CPU utilization , in this we allow more
than one program to reside in RAM
• This is also known as Degree of multiprogramming.
It represent how many process reside in Main
memory.
• As we increase DOM, CPU utilization also
increases.
• When any process leaves for I/O , other process is
scheduled to the CPU.
• At a time only process is processed by CPU.
Advantages of Multi-Programming Operating
System
• Multi Programming increases the Throughput of
the System.
• It helps in reducing the response time.
Disadvantages of Multi-Programming Operating
System
• There is not any facility for user interaction of
system resources with the system.
Multitasking OS
• It is also known as pre-emptive version
of Multiprogramming
• It is simply a multiprogramming
Operating System with having facility
of a Round-Robin Scheduling
Algorithm.
• It can run multiple programs
simultaneously.
• But user are unaware of it.
Advantages of Multi-Tasking
Operating System
• Better user responsiveness.
Disadvantages of Multi-Tasking
Operating System
• User interaction is only one at a time.
Multiprocessing OS
• More than one CPU reside in the
system.
• Enhanced Throughput and
robustness is seen.
• Generally, of two types
• Tight coupled (shared ) – each cpu
has common shared memory
• Loose coupled- each cpu has
different memory.
Real Time OS
• 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.
• Generally of two types
• Hard RTOS- strict response time e.g. missile,
airbags system
• Soft RTOS- deadline can be little bit delay e.g.
banking, streaming.
Distributed Operating System
• Various autonomous interconnected
computers communicate with each other
using a shared communication network.
• Independent systems possess their own
memory unit and CPU.
• These are referred to as loosely coupled
systems or distributed systems.
• High availability and robustness
Advantages of Distributed Operating System
• Failure of one will not affect the other network
communication, as all systems are
independent of each other.
• Scalable, and load balanced
Disadvantage
• Synchronization
Embedded OS
• Designed for specific purpose.
• Basically embedded in machine to make them smart.
• E.g. Microwave, AC
• User interaction with OS is minimum.
• Rigid in nature-( once developed cannot be easily
reprogrammed).
Unit 2 – Process Management
What is Process?
• Program under execution is known as Process.
• Initially the program is stored in secondary memory.
• For execution it has to brought in Main memory.
• Process management involves identifying the steps involved in
completing a task, assessing the resources required for each
step, and determining the best way to execute the task.
• Stack- local variables, function
• Heap –dynamic memory allocation
• Data – information
• Text- current activity description
Process Attributes
• A process has the following attributes.
• Process Id: A unique identifier assigned by the operating system.
• Process State: Can be ready, running, etc.
• Program Counter
• List of General-purpose Registers
• Priority Info
• List of files
• List of devices.
• All of the above attributes of a process are also known as the context of the process.
• Every process has its own process control block(PCB), i.e. each process will have a
unique PCB.
• This PCB info is also stored in RAM.
Process State
• A process is in one of the following states:
• New: Newly Created Process (or) being-created process.(App downloaded)
(secondary memory)
• Ready: After the creation process moves to the Ready state, i.e. the process is ready
for execution. (Main memory )
• Run: Currently running process in CPU (only one process at a time can be under
execution in a single processor) (Main memory). (dispatcher)
• Wait (or Block): When a process requests I/O access.(Main memory)
• Complete (or Terminated): The process completed its execution.(out of Main memory)
• Suspended Ready: When the ready queue becomes full, some processes are moved
to a suspended ready state
• Suspended Block: When the waiting queue becomes full.
• When any process changes its state , context switching happen.
Context Switching of Process
• The process of saving the context of one process and loading the context of another process is
known as Context Switching. In simple terms, it is like loading and unloading the process from
the running state to the ready state and vice -versa.
• It is performed by dispatcher . It is small program that perform context switching.
• When Does Context Switching Happen?
• 1. When a high-priority process comes to a ready state (i.e. with higher priority than the running
process).
2. An Interrupt occurs.
3. User and kernel-mode switch (It is not necessary though)
4. Preemptive CPU scheduling is used.
CPU-Bound vs I/O-Bound Processes
• A CPU-bound process requires more CPU time or spends more time in the running
state. An I/O-bound process requires more I/O time and less CPU time. An I/O-bound
process spends more time in the waiting state.
• Process planning is an integral part of the process management operating system. It refers
to the mechanism used by the operating system to determine which process to run next.
The goal of process scheduling is to improve overall system performance by maximizing
CPU utilization, minimizing execution time, and improving system response time.
Scheduling Queue
• Job queue- to store processes of new
state.
• Ready Queue- to store processes of
ready state.
• Device Queue- to store processes of
wait state.
Types of scheduler:
• Long term scheduler(Job): bring job
from new to ready state.
• Short term scheduler (CPU): bring job
from ready to running state.
• Middle term scheduler: from ready to
suspended state.
What are the different
Objectives of Process Scheduling terminologies to take care of in
Algorithm:
•Utilization of CPU at maximum level. Keep
any CPU Scheduling algorithm?
•Arrival Time: Time at which the process arrives in
CPU as busy as possible.
the ready queue.
•Allocation of CPU should be fair.
•Completion Time: Time at which process
•Throughput should be Maximum. i.e.
completes its execution.
Minimum turnaround time, i.e. time taken by •Burst Time: Time required by a process for CPU
a process to finish execution should be the execution.
least. •Turn Around Time: Time Difference between
•There should be a minimum waiting completion time and arrival time.
time and the process should not starve in the Turn Around Time = Completion Time – Arrival
ready queue. Time
•Minimum response time. It means that the •Waiting Time(W.T): Time Difference between
time when a process produces the first turn around time and burst time.
response should be as less as possible. Waiting Time = Turn Around Time – Burst Time
Types of Scheduling
• Preemptive Scheduling:
Preemptive scheduling is used
when a process switches from
running state to ready state or
from the waiting state to the
ready state.
• Non-Preemptive Scheduling:
Non-Preemptive scheduling is
used when a process terminates
, or when a process switches
from running state to waiting
state.
FCFS (First Come First Serve)
Criteria:
• Scheduled based on arrival time
• If tie – then prefer process with low
process id.
Type:
• Non-pre-emptive
• To solve question we draw Gantt
chart , that keep tracks of process
order execution.
• It always start with zero
• Ready Queue- P1, P2, P3
TAT= CT- AT
WT= TAT- BT
Response time- first
time it get chances of
CPU
P1= 0
P2= 27
P3= 33
• Convoy Effect :
• If the first process arrived in
system has long burst time, then
all the remaining process waiting
time increases.
• Short term process may have also
to wait long.
• FCFS faces this problem.
Shortest Job First( SJF)
Criteria :
• Burst time or Execution Time
• Tie Breaker- arrival time and process id.
Type:
• Non-preemptive
Advantages of Shortest Job first:
• As SJF reduces the average waiting time thus, it
is better than the first come first serve
scheduling algorithm.
• Disadvantages of SJF:
• One of the demerit SJF has is starvation.
• Not practically implemented as Burst time of
process in advance is unknown.
Shortest Remaining Time First(SRTF)
Criteria :
• Burst time or Execution Time
• Tie Breaker- arrival time and process id.
Type:
• Preemptive (so short process arrives it pre-
empt already running process)
Advantages of Shortest Job first:
• In SRTF the short processes are handled
very fast.
• Disadvantages of SJF:
• One of the demerit SJF has is starvation.
• Not practically implemented as Burst time
of process in advance is unknown.
Note : In case of Pre-emption, waiting and response time
is different while in non-pre-emption it is same.
Priority Based Scheduling
Criteria:
• Based on Priority, we scheduled
processes.
• Mostly priority is unique for each process.
In case tie breaker, question always give
hint.
Type:
• Pre-emptive and Non-preemptive.
• Higher number or small number is given
what priority given in question.
• Starvation problem.
• When Solve using pre-emptive nature.
Starvation and its Counter Measure
• Starvation is the problem that occurs when high priority processes keep executing
and low priority processes get blocked for indefinite time.

• In heavily loaded computer system, a steady stream of higher-priority processes


can prevent a low-priority process from ever getting the CPU.

• In starvation resources are continuously utilized by high priority processes.

• Problem of starvation can be resolved using Aging.

• In Aging priority of long waiting processes is gradually increased.


Round Robin
• Criteria:
• Arrival time + time quantum
• Time quantum is the maximum time for which a process is
assigned the cpu, and after this time cpu is pre-empted from
process.
• In case tie breaker, the process id with lower is preferred.
• E.g.- fielding practices.
Type:
Preemptive.
Note:- Choosing time quantum is very critical. Small- low cpu efficiency, high- low user interaction(fcfs)

You might also like