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

2-OS LECTURE

Uploaded by

abdullahzahidhp
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)
3 views

2-OS LECTURE

Uploaded by

abdullahzahidhp
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
You are on page 1/ 40

CSC351-OPERATING SYSTEM

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 :

 Lack of interaction between the user and the job.


 CPU is often idle, because the speed of the mechanical I/O devices is slower than the CPU.
MEMORY LAYOUT OF BATCH SYSTEMS

LAHORE GARRISON UNIVERSITY 6


BATCH SYSTEM (CONTI…)

LAHORE GARRISON UNIVERSITY 7


MULTIPROGRAMMED SYSTEMS

 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

LAHORE GARRISON UNIVERSITY 8


MULTIPROGRAMMED SYSTEMS

 Example: Two processes P1 and P2 with CPU and I/O bursts of one
time unit each

LAHORE GARRISON UNIVERSITY 9


OS FEATURES NEEDED FOR MULTIPROGRAMMING

► Spooling (Simultaneous
Peripheral Operation On-
Line)(put job in buffer)
► Memory management
► CPU scheduling

LAHORE GARRISON UNIVERSITY 10


TIME SHARING SYSTEMS

► The Time-sharing systems are also called Multitasking systems.


In Time-sharing operating system, we assign some time to each
job so that all the jobs work efficiently and smoothly.
► The time taken by each job to execute the job is known as
quantum. After the interval of time is over, the operating system
moves to the next task.
► The major difference between Time-sharing operating system
and Multiprogramming batch operating system is that the time-
sharing operating system aims to minimize the response time,
whereas the Multiprogramming batch operating system is to
increase the use of the processor.
LAHORE GARRISON UNIVERSITY 11
MULTIPROCESSOR OPERATING SYSTEM

 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

► Well-defined fixed-time constraints.


► Often used as a control device in a dedicated application such as
controlling scientific experiments, medical imaging systems,
industrial control systems, and some display systems. Plane landing.
Ventilators.
► Real-Time systems may be either hard or soft real-time.

LAHORE GARRISON UNIVERSITY 15


REAL TIME SYSTEMS

Hard real-time systems:


► Secondary storage limited are absent, data stored in short term memory, or read-only memory
(ROM).coz time is short
► No virtual memory—time cannot be “wasted” on translation of logical to physical addresses.
► OS code structured for efficiency
► Plane landing systems, process control in nuclear power plants, ventilators, etc.

LAHORE GARRISON UNIVERSITY 16


REAL TIME SYSTEMS (CONT..)

Soft real-time systems


► Output should be produced within the given time constraints but if it is not, the result is not life threatening.
► Useful in applications (Live Video Streaming) requiring advanced operating-system features
 Mobile Communication
 Music Playing Robots
 Weather Station

LAHORE GARRISON UNIVERSITY 17


OPERATING SYSTEM OPERATIONS
INTERRUPTS

 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

 If you press any key(keyboard) or moving the mouse…..Example of interrupt


 Hardware may trigger an interrupt at any time by sending a signal to the CPU
usually by way of the system bus.
 Software may trigger an interrupt by executing a special operation called a
system call
Answer
the Phone
.
.
.
21

Resume
INTERRUPTS, TRAP, SIGNALS

► A process can generate a trap, for example, by dividing a number by zero.


► caused either by an error (division by zero or invalid memory access) or by a user request for an operating system
service.
► A user or a process may generate a signal (an interrupt to a process)

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.

LAHORE GARRISON UNIVERSITY 24


FETCH – EXECUTE CYCLE
PROTECTION

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

 Dual-mode operation allows OS to protect itself and other system components


 privileged instructions
 It contains user mode (mode bit:1) and Kernel mode (mode bit:0)
 The operating system loaded user application starts in user mode. Whenever a trap or interrupt occurs,
hardware switches to kernel mode.
PRIVILEGED INSTRUCTIONS

 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

▪Must provide memory protection outside the address space of a process.

▪In order to have memory protection, add two registers that determine the range of legal addresses a program may access:

▪Base register – holds the smallest legal physical memory address.

▪Limit register – contains the size of the range

▪Memory outside the defined range is protected.


USE OF BASE AND LIMIT REGISTER
HARDWARE SUPPORT
CPU PROTECTION

▪Timer – interrupts computer after specified period to ensure operating system maintains control.

▪Timer is decremented every clock tick.

▪When timer reaches the value 0, an interrupt occurs.

▪Timer commonly used to implement time sharing.

▪Time also used to compute the current time.

▪Load-timer is a privileged instruction.


REFERENCE

 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

You might also like