2-OS LECTURE
2-OS LECTURE
Week-1 (Lecture-2)
Semester 05
Prepared by:
Aisha Riaz
RECAP
What is hardware
What is software
Operating system
Components of computers
Two types of views
Functions of Operating system
Example of Operating system
Types of Operating Systems
• Batch systems
• Multiprogramming systems
• Time-sharing systems/multitasking Systems
• Real-time systems
• Distributed System
• Interrupts, traps, and signals
• CPU, I/O, and memory protection
BATCH SYSTEMS
❑ The users of a batch operating system do not interact with the computer directly.
❑ Each user prepares his job on an off-line device like punch cards and submits it to the computer
operator. To speed up processing, jobs with similar needs are batched together and run as a group.
❑ The programmers leave their programs with the operator and the operator then sorts the programs
with similar requirements into batches.
4
THE PROBLEMS WITH BATCH SYSTEMS ARE AS FOLLOWS :
In Multiprogramming Operating System, the Operating system first selects the job, and
after selecting the job, it begins to execute one of the jobs from memory. When this
job requires an I/O operation operating system, it switches to another job (operating
system and CPU always busy).
In a simple batch operating system, sometimes CPU is idle and doesn’t perform any
task, but in the multiprogramming batch operating system, CPU is busy and will never
sit idle and always keeps on processing
Example: Two processes P1 and P2 with CPU and I/O bursts of one
time unit each
► Spooling (Simultaneous
Peripheral Operation On-
Line)(put job in buffer)
► Memory management
► CPU scheduling
A Multiprocessor Operating System means the use of two or more processors within a single computer
system.
These multiple processors are in close communication and share the memory, computer bus, and other
peripheral devices.
These systems are known as tightly coupled systems. It offers high speed and computing power. In
Multiprocessor operating system, all the processors work by using a single operating system.
ADVANTAGES OF MULTIPROCESSOR
Improved performance.
By maximizing the number of processors, more work is done in less time. In this way, throughput is increased.
Increased reliability.
DISTRIBUTED OPERATING SYSTEM
The major benefit of working with these types of the operating system is that it is always possible that one user
can access the files or software which are not actually present on his system but some other system connected
within this network i.e., remote access is enabled within the devices connected in that network.
These are referred to as loosely coupled systems or distributed systems.
REAL TIME SYSTEMS
Interrupts are signals sent to the CPU by external devices, normally I/O devices. They tell the CPU to stop its
current activities and execute the appropriate part of the operating system
INTERRUPTS, TRAPS AND SIGNALS
Interrupt---an event generated by a device in a computer to get attention of the CPU(from hardware devices)
Trap—an event by the CPU itself as it executes a program
Signal—an event generated by a user
20
INTERRUPTS, TRAP, SIGNALS
Resume
INTERRUPTS, TRAP, SIGNALS
22
INTERRUPT HANDLING
► In case of interrupt or trap, the CPU invokes a piece of code in the OS to service it, known as interrupt service
routine(ISR) or trap service routine(TSR)
► In case of signal, the process can take one of the three possible actions , default action as defined by OS, ignore
signal, or take a programmer specified action
23
INTERRUPT HANDLING (CONT..)
► Interrupt transfers control to the interrupt service routine, generally, through the interrupt vector, which
contains addresses of all the interrupt service routines.
► Interrupt architecture must save the address of the instruction after the interrupted instruction and the CPU
state so that execution of the interrupted process may continue after the interrupt has been serviced.
As we have time sharing system so multiple user may be there. Here comes the issue of protection
We need to make sure that an error in a user program could hurt only that program
in multiprogramming environment one program can cause problems for other programs or even for OS
One user may delete the files of others.
Or may overwrite program in memory
Without protection; Only one process at a time or suspected output always
HARDWARE PROTECTION
►Dual-Mode Operation
►I/O Protection
►Memory Protection
►CPU Protection
28
DUAL-MODE OPERATION
The Instructions that can run only in Kernel Mode are called Privileged Instructions
Not executed in user mode
Used by the OS
Examples:
I/O instructions and Halt instructions
Turn off all Interrupts
Set the Timer
Context Switching
Clear the Memory or Remove a process from the Memory
Modify entries in Device-status table
Switch from User to Kernel Mode
NON-PRIVILEGED INSTRUCTIONS
The Instructions that can run only in User Mode are called Non-Privileged Instructions
Examples:
Reading the status of Processor
Reading the System Time
Generate any Trap Instruction
Sending the final printout of Printer
DUAL MODE OPERATION
12/3/2024
5.1 DUAL MODE OPERATION…
#include<stdio.h>
Int main()
{
…
printf(“hellow world”);
…
}
User mode
Standard C library
Kernel mode
Write()
system
call 12/3/2024
I/O PROTECTION
• A user process may disrupt the normal operation of the system by issuing illegal I/O instructions, by accessing
memory locations within the operating system itself, or by refusing to surrender the CPU.
• We can use various mechanisms to ensure that such disruptions cannot take place in the system
I/O Protection
▪ All I/O instructions are privileged instructions.
▪ Thus users cannot issue I/O instructions directly; they must do it
through the operating system.
▪ Must ensure that a user program could never gain control of the
computer in monitor mode (i.e., a user program that, as part of its
execution, stores a new address in the interrupt vector) execution,
stores a new address in the interrupt vector).
MEMORY PROTECTION
▪In order to have memory protection, add two registers that determine the range of legal addresses a program may access:
▪Timer – interrupts computer after specified period to ensure operating system maintains control.
To cover these topics, different reference material has been used for consultation.
Operating Systems Concept by Abraham Siberchatz edition 9
Tutorialspoint.com
Google.com
40