Chapter 16a-OS
Chapter 16a-OS
OPERATING SYSTEM
▪ An operating system can provide facilities to have
more than one program stored in memory.
▪ Only one program can access the CPU at any given
time, but others are ready when the opportunity arises.
This is described as multi-programming.
▪ Multiprogramming OS is an ability of an operating
system that executes more than one program using a
single processor machine.
▪ This is for single user system.
▪ System with many users(logged in simultaneously),
known as time-sharing system.
OPERATING SYSTEM
Main purpose of an operating system:
▪ Internal = manage the computer's resources provides an
atmosphere in which various programs and apps can do useful
work
▪ External = Facilities provided for system usage. (Chapter 5)
OPERATING SYSTEM
The three fundamental resources in a computer system are:
▪ CPU
▪ Memory
▪ I/O System
A CPU typically operates at GHz frequencies,
IO devices are slower.
CPU management is vital to ensure a good
utilization of CPU recourse(CPU not idle while waiting
I/O is taking place.
OPERATING SYSTEM
0.1s to transfer 1 byte
▪ Ready - This is where the process is loaded into memory, ready to be executed.
▪ Blocked - This is where the process is waiting for an event to occur before it is
processed.
INTERRUPTS
▪ An interrupt is a signal emitted by a device attached to a
computer or from a program within the computer. It requires the
operating system (OS) to stop and figure out what to do next.
▪ An interrupt temporarily stops or terminates a service or a
current process. Most I/O devices have a bus control line called
Interrupt Service Routine (ISR) for this purpose.
▪ An interrupt signal might be planned (i.e., specifically requested
by a program) or it may be unplanned (i.e., caused by an event
that may not be related to a program that's currently running on
the system).
▪ The OS kernel will invoke an interrupts-handling routine. It will decide the priority of the
interrupt. The current value stored in registers must be stored in the process control
block.
INTERRUPTS
Types of Interrupt
1. 1-I/O interrupt: Generated by an I/O
device that a job is complete or an error
has occurred. Example “Printer is out of
paper or printer is not connected.”
2. Time interrupt: Generated by an internal
clock indicating that the processor must
attend to time critical activities.
3. Hardware interrupt: For example, power
failure which indicated that the OS must
close down as safely as possible. The OS must see if an interrupt has occurred. If one
has occurred, the OS must service the interrupt in
4. Program interrupt: Generated due to an the case that it is more important than the task
error in a program such as violation of already being carried out. Interrupts are saved in a
memory use (trying to use part of the queue (FIFO) that holds the next interrupt that have
memory reserved by the OS for other use) to be dealt with.
or an attempt to execute an invalid
instruction (division by zero).
SCHEDULING ALGORITHMS
There are multiple scheduling algorithms that can be used, depending on the system.
These include:
• Round Robin
• First Come First Served
• Short Job First
• Shortest Remaining Time First
ROUND ROBIN SCHEDULING
▪ Each process is assigned an equal time
slot(aka quantum) for execution. P1
▪ Once the quantum time has been reached
the process is blocked and will have to
wait until the next time round to carry on
executing.
▪ If a process completes before it reaches, P4 P2
it's quantum limit then itself terminates the
processor moves onto the next process.
P3
1 2 3 4 1 2 3 4 1 2 3 4
ROUND ROBIN SCHEDULING
In round-robin scheduling the processor works on each process in a circular manner.
Each process is assigned an equal time-slice (aka quantum) for execution.
Once the time-slice has been used up the process is blocked and will have to wait until
the next time round to carry on executing. If a process completes before it reaches, it’s
quantum limit then itself terminates the processor moves onto the next process.
Advantages
• All processes are treated equally
• All processes are guaranteed to be processed eventually
Disadvantages
• Results in a high average waiting time
FIRST COME FIRST SERVED
SCHEDULING
Here jobs are executed in the order in which they arrived. All processes are guaranteed
to be processed, but results in high average waiting times.
1 2 3 4
Advantages
• All processes will be processed eventually.
Disadvantages
• Large processes will cause a bottleneck (Convoy Effect)
SHORTEST JOB FIRST SCHEDULING
Here the process with the shortest estimated burst time is executed first. As new
processes arrive their estimated burst is compared with the current process to see which
process is to be executed.
2 2 4 4 1 1 1 3 3 3 3 3
Advantages
• Can result in a lower average waiting time
Disadvantages
• Requires the ability to accurately estimate burst times
• Can result in priority inversion, depending on the system
SHORTEST REMAINING TIME FIRST
SCHEDULING
Here the job with the least amount of remaining burst time is processed first. If a new
job arrives with a shorter burst time than the job currently being executed, then the
current job is moved to the blocked queue and the new job is executed.
Useful in batch systems where smaller jobs need to be given priority.
▪ Advantages
• Can result in the lowest average waiting time
▪ Disadvantages
• A certain amount of processing time is required to calculate remaining burst times and
switch between tasks (context switching)
• The system must be able to accurately estimate burst times for each process,
therefore SRTF can only be used in certain systems.
▪ https://drive.google.com/drive/folders/16FLTFcTqskvQQiFeT3sTDPxm81GooTle
VIRTUAL MACHINE
▪ Virtual Machine is like fake computer system operating on your hardware. It partially
uses the hardware of the system (like CPU, RAM, disk space, etc.) but its space is
completely separated from your main system.
▪ These types of virtual machines gives complete system platform and gives the
execution of the complete virtual operating system.
▪ Just like virtual box, system virtual machine is providing an environment for an OS to
be installed completely. We can see in the next image that our hardware of Real
Machine is being distributed between two simulated operating systems by Virtual
machine monitor.
VIRTUAL MACHINE