Purpose of An Operating System
Purpose of An Operating System
Operating System
Applications
Operating System
Example
Clicking on an icon instead of writing code simplifies interactions.
Using a graphical user interface (GUI) with icons for navigation
makes computing more user-friendly.
Resource Management
Question : What are resources ?
C.P.U
Memory
Input / Output devices
Memmory
Secondary Main
Memory Memory
(HDD) (RAM)
Multitasking
Multitasking in an operating system allows a user to
perform more than one task at a time.
Preemptive
Resources are allocated to a process for a limited time.
The process can be interrupted while it is running.
More flexible form of scheduling.
Non Preemptive
Once the resources are allocated to a process, the process retains
them until it has completed its burst time (amount of time
required by a process for executing on CPU).
The process cannot be interrupted while running (It must finish or
switch to waiting state).
More rigid form of scheduling.
State 1 : Ready
Description:
State 2 : Running
Description:
State 3 : Blocked
Description:
READY → RUNNING
RUNNING → READY
RUNNING → BLOCKED
Scheduler
High Level Scheduler: Decides which processes are to be loaded
from backing store into ready queue.
with SJB, the process requiring the least CPU time is executed first
Ready
Running
Description:
FCFS scheduling processes requests in the order they
arrive. Each process is queued as it is received and
executed one by one, without preemption.
It follows a non-preemptive approach, meaning once a
process starts execution, it runs until completion.
Benefits:
Simple and easy to implement as it does not require
complex scheduling logic.
Prevents starvation, ensuring every process will
eventually get a chance to run.
Low overhead as there is no need for frequent context
switching.
Drawbacks:
Poor response time for long processes, as shorter jobs
must wait for long ones to finish.
Can lead to convoy effect, where short processes are
stuck waiting behind long processes.
Not suitable for time-sharing systems, as it does not
allow preemption.
Shortest Job First (SJF) Scheduling
Description:
SJF scheduling selects the process with the shortest CPU
burst time and executes it first.
It is non-preemptive, meaning once a process starts, it
runs to completion before the next shortest process is
selected.
Benefits:
Increases throughput, as shorter processes finish
quickly, allowing more processes to be executed in less
time.
Minimizes average waiting time, as shorter processes do
not have to wait for long-running processes.
Drawbacks:
Can cause starvation, as long-running processes may
never get CPU time if short jobs keep arriving.
Difficult to implement, as it requires knowing the exact
burst time of processes beforehand.
Not ideal for dynamic environments, where process
execution times may change.
Shortest Remaining Time First (SRTF) Scheduling
Description:
Preemptive
The processes are placed in ready queue as they arrive
But when a process with the shortest burst time arrives
the existing process is removed
The shorter process is then executed first
Benefits:
More responsive than SJF, as shorter jobs can interrupt
longer ones.
Minimizes average turnaround time by prioritizing short
tasks.
Efficient CPU utilization, reducing idle time.
Drawbacks:
Can cause high overhead, as frequent context switching
occurs when new shorter processes arrive.
Starvation of long processes, as they may keep getting
preempted by shorter jobs.
Requires accurate estimation of remaining CPU time,
which is difficult in real-world scenarios.
Round Robin (RR) Scheduling
Description:
RR assigns a fixed time slice (quantum) to each process in
a cyclic order.
If a process does not finish within its time slice, it is
preempted and moved to the back of the queue.
Benefits:
Ensures fairness, as every process gets CPU time equally.
Prevents starvation, since all processes receive
execution time in each cycle.
Better responsiveness, making it suitable for time-
sharing systems and multi-user environments.
Drawbacks:
High context switching overhead, especially if the time
slice is too small.
Inefficient for long processes, as they require multiple
cycles to complete.
Performance depends on time quantum selection – too
small leads to excessive switching, too large behaves like
FCFS.
Interrupt Handling
Concept Of Paging
Rest of pages which are not present in main memory they are
stored in Hard drive.
Page Replacement
Page replacement occurs when a requested page is not in
memory (flag = 0). When paging in/out from memory, it is
necessary to consider how the computer can decide which
page(s) to replace to allow the requested page to be loaded.
When a new page is requested but it is not in memory a page
fault occurs.
Paging Segmentation
Question 1
Answer 3
Answer 5
Answer 10
Answer 12