Operating System (Types of Operating System) : Department of Computer Science University of Swabi (Khyber Pakhtunkhwa)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Operating System (Types of Operating System)

Department of Computer Science


University of Swabi (Khyber Pakhtunkhwa)

Fall 2017 Semester


BS Course: Operating System

Course Instructor: Anwar Hussain


Agenda for Today
 Review of previous lecture
 Single-user systems
 Batch systems
 Multi-programmed systems
 Time-sharing systems
 Real-time systems
 Interrupts, traps, and signals
 CPU, I/O, and memory protection
 Recap of the lecture

Wednesday, 20 September, 2017 University of Swabi (KPK)


Single User System
 Allow only one user to use the computer at any given time
 Example
 Personal computers – computer system dedicated to a single user.

 Goal of single user operating system


 User convenience and responsiveness

 Can adopt technology developed for larger operating systems—multi-process, multi-user

 Individuals usually have sole use of computer and do not need advanced protection features.

 May run several different types of operating systems (Windows, MacOS,


UNIX, Linux)

Wednesday, 20 September, 2017 University of Swabi (KPK)


Single User System

Wednesday, 20 September, 2017 University of Swabi (KPK)


Batch Systems
 Early Computers processing
 Early computers were large machines run from a console with card readers and tape drives as
input devices and line printers, tape drives, and card punches as output devices

 Limitations
 The user did not interact directly with the system; instead the user prepared a job, (which
consisted of the program, data, and some control information about the nature of the job in the
form of control cards) and submitted this to the computer operator.
 The job was in the form of punch cards, and at some later time the output was
generated by the system user didn’t get to interact with his/her job. The output
consisted of the result of the program.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Batch Systems
 First rudimentary system.
 No interaction of user to the system, user prepared job submitted it to the operator

 Speeding up processing
 Reduce setup time by batching similar jobs
 All FORTAN programs were compiled one after another
 CPU idle because of mechanical I/O devices (drawback)

 Major task of operating system


 Automatic job sequencing i.e.,
automatically transfers control from one job to another.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Batch Systems

Wednesday, 20 September, 2017 University of Swabi (KPK)


Memory Layout

 Operating system space


 Operating system code
 Data currently in use

 User space
 User programs (processes)
 Only one process in allow

Wednesday, 20 September, 2017 University of Swabi (KPK)


Multi-Programmed Systems
 Several jobs are kept in main memory at the same time, and the CPU is multiplexed
among them.
 This set of jobs is a subset of the jobs on the disk which are ready to
run but cannot be loaded into memory due to lack of space

 When CPU switches to other job?


 When job is executed and it start wait for I/O event, then CPU picks
another job
 Example:
 Two processes P1 and P2 with CPU and I/O bursts of one time
unit each

Wednesday, 20 September, 2017 University of Swabi (KPK)


Multi-Programmed Systems

Wednesday, 20 September, 2017 University of Swabi (KPK)


Multi-Programmed Systems
 Job pool
 Jobs enter in the system are kept in the job pool (disk)
 Jobs are brought in the memory for execution

 Jobs scheduling
 If several jobs are waiting to be brought in the memory and there is no enough space then
CPU select jobs among them which is know as scheduling

Wednesday, 20 September, 2017 University of Swabi (KPK)


Time-sharing Systems
 Time sharing systems is
 Multi-user – allow multiple users to use the computer
 Multi-process – user can run more than one processes and interact with them

 Uses multiprogramming and CPU scheduling to provide portion of time to each user

 To provide better response time


 A job is swapped in and out of memory to the disk if needed.

 Example
 UNIX, Linux, Windows NT server and Windows 2000 server

Wednesday, 20 September, 2017 University of Swabi (KPK)


Real-Time Systems
 Real time systems are used when
 rigid time requirements are placed on the operation of a processor or the flow of data
 thus it is often used as a control device in a dedicated application.

 Examples
 Systems that control scientific experiments, medical imaging systems, industrial control systems
and certain display systems

 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.

 Well-defined fixed-time constraints. if system does not produce within time constraints it will be
failed.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Real-Time Systems
 Hard real-time systems:
 Guarantees that critical tasks be completed on time
 Secondary storage limited or absent, data stored in short term memory, or read-only memory
(ROM)
 No virtual memory—time cannot be “wasted” on translation of logical to physical addresses
 OS code structured for efficiency
 Examples
 Plane landing systems, process control in nuclear power plants, respirators, etc.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Soft real time System
 Soft real-time systems
 Critical real-time task gets priority over other tasks, and retains that priority until it completes
 Output should be produced within the given time constraints but if it is not, the result is not
life threatening
 Useful in applications (multimedia, virtual reality) requiring advanced operating-system
features.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Interrupts, Traps and Signals
 What is an Interrupt
 A signal generated by a hardware device (usually an I/O device) to get CPU’s attention
 Signal is an event generated to get attention of a process.

 The occurrence of an event is usually signaled by an interrupt from either the hardware
or the software.
 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.
 A user or a process may generate a signal (an interrupt to a process)

Wednesday, 20 September, 2017 University of Swabi (KPK)


Interrupt Handling
 When an Interrupt occurs, then
 Interrupt transfers control to the interrupt service routine (ISR), 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
 Incoming interrupts are disabled while another interrupt is being processed to prevent lost
interrupts.
 An operating system is interrupt driven.

 Trap (an exception)


 software-generated interrupt caused either by an error (division by zero or invalid memory
access) or by a user request for an operating system service.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Hardware Protection
 Why do we need Hardware Protection?
 Multi-programing: Several programs are in memory at the same time, could result in the following
problems
 One erroneous program could also modify the program or data of another program, even
operating system files.
 File may overwrite another file or folder on disk.
 Process may not leave the CPU before it is finished.

 Hardware Protection Issues


 I/O Protection
 Memory Protection
 CPU Protection

 First we will discuss Dual-Mode Operation

Wednesday, 20 September, 2017 University of Swabi (KPK)


Dual-Mode Operation
 Sharing system resources requires operating system to ensure that an incorrect program
cannot cause other programs to execute incorrectly.
 Protection is needed for any shared resource

 Modern system instruction set has two kinds of instructions


 privileged instructions: used to perform hardware operations that a normal user process
should not be able to perform (e.g., communicating with I/O devices).
 non- privileged instructions: Normal user processes

 What should be the strategy?


 A piece of operating system code should be allowed to execute privileged instructions

Wednesday, 20 September, 2017 University of Swabi (KPK)


Dual-Mode Operation
 Provide hardware support to differentiate between at least two modes of operations.
 User mode – execution done on behalf of a user.
 Monitor mode (also kernel mode or system mode) – execution done on behalf of operating system.

 Concept of privileged instructions also provides us with the means for the user to interact with the
operating system by asking it to perform some designated tasks that only the operating system should
do
 Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1).
 User process can request the operating system to perform such tasks for it by executing a system call

 When an interrupt or fault occurs


 hardware switches to monitor mode before executing relevant kernel code

 Privileged instructions can be issued only in monitor mode

Wednesday, 20 September, 2017 University of Swabi (KPK)


Dual-Mode Operation

Wednesday, 20 September, 2017 University of Swabi (KPK)


I/O Protection
 User process can disturb the normal operation of the system
 could cause illegal I/O instruction
 Accessing OS memory locations
 refusing to relinquish the CPU

 To prevent users from performing illegal I/O, we define


 All I/O instructions are privileged instructions.
 User is not able to issue I/O instruction directly; they must do it through OS.

 We 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).

Wednesday, 20 September, 2017 University of Swabi (KPK)


Memory Protection
 Process address space
 The memory that a process is allowed to access.

 Must provide memory protection outside the address space of a process because
 it can access and can accidentally overwrite the address space of another process
 or memory belong to OS

 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 (starting address of the process).
 Limit register – contains the size of the range

 Memory outside the defined range is protected using Base and Limit registers.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Use of Base and Limit Register
 Starting address of Process = 300040
 Size of the Process = 120900

 Assuming the memory is byte addressable

 All addresses generated by the process must be


 Greater or equal to Base Address (e.g., 300040) and
 Less than Limit Register.
i.e., (300040 + 120900) = 420940

 Loading Base and Limit registers are privileged


instructions

Wednesday, 20 September, 2017 University of Swabi (KPK)


Use of Base and Limit Register …

Wednesday, 20 September, 2017 University of Swabi (KPK)


CPU Protection
 We must ensure that the OS maintains the control
 prevent user program from getting stuck in an infinite loop or not calling system services and never
returning control to the CPU

 Timer – interrupts computer after specified period to ensure operating system maintains control.
 can be fixed or variable
 fixed-rate clock + counter = variable timer
 Timer r is decremented every clock tick.
 When timer reaches the value 0, an interrupt occurs.

 Applications
 Timer commonly used to implement time sharing.
 Time also used to compute the current time.

 Load-timer is a privileged instruction.

Wednesday, 20 September, 2017 University of Swabi (KPK)


Any Question?

Thank you

Wednesday, 20 September, 2017 University of Swabi (KPK)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy