Week 1 Lec 2

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

OPERATING SYSTEMS

(CSC 2205)

Department of Computer Science


SZABIST, Islamabad 1
WEEK 1 LEC 2

GCR CODE BSCS-5B: ua7vtjp

2
OUTLINES
• Single-user systems
• Batch systems
• Multiprogrammed systems
• Time-sharing systems
• Real-time systems
• Interrupts, traps, and signals
• CPU, I/O, and memory protection
• Recap of the lecture

3
SINGLE USER SYSTEMS

• Personal computers – computer system dedicated to a single user.


• Interactive
• 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 (now a days its important).
• May run several different types of operating systems
(Windows, MacOS,UNIX, Linux)

4
BATCH SYSTEMS

• First rudimentary system.


• User ≠ operator
• Reduce setup time by batching similar jobs (how?)
• Automatic job sequencing – automatically transfers control from one job to
another.
• Resident monitor : Early OS 1950-1970
• initial control in monitor
• control transfers to job
• when job completes control transfers back to monitor

5
MEMORY LAYOUT

6
MULTIPROGRAMMED SYSTEMS

• Several jobs are kept in main memory at


the same time, and the CPU is
multiplexed among them.
• How?

7
MULTIPROGRAMMED SYSTEMS

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

CPU I/O
Burst Burst

P1
P2

P1

P2
8
OS FEATURES NEEDED FOR MULTIPROGRAMMING

• SPOOLing (Simultaneous Peripheral Operation On-Line)


• Memory management
• CPU scheduling

9
TIME-SHARING SYSTEMS

• An interactive system with multiprogramming


• A job is swapped in and out of memory to the disk if needed.
• On-line file system must be available for users to access data and
code.

10
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.
• Real-Time systems may be either hard or soft real-time
• Hard real-time systems:
• 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
• Plane landing systems, process control in nuclear power plants,
respirators, etc.

11
REAL-TIME SYSTEMS ...

• 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 (multimedia, virtual reality) requiring advanced
operating-system features.

12
INTERRUPTS, TRAPS, AND SIGNALS

• 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 process can generate a trap, for example, by dividing a number by zero.
• A user or a process may generate a signal (an interrupt to a process)

13
INTERRUPT HANDLING

• 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.
• Incoming interrupts are disabled while another interrupt is being
processed to prevent lost interrupts.
• An operating system is interrupt driven.

14
HARDWARE PROTECTION

• Dual-Mode Operation
• I/O Protection
• Memory Protection
• CPU Protection

15
DUAL-MODE OPERATION

• Sharing system resources requires operating system to ensure


that an incorrect program cannot cause other programs to
execute incorrectly.
• 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.

16
DUAL-MODE OPERATION …

• Mode bit added to computer hardware to indicate the current mode:


monitor (0) or user (1).
• When an interrupt or fault occurs hardware switches to monitor mode.

Interrupt/fault

monitor user
set user mode

Privileged instructions can be issued only in monitor mode.

17
MEMORY MANAGEMENT

• Basic concepts
• Various techniques for memory management
• Logical to physical address translation
• Swapping
• Contiguous memory allocation: MFT, MVT
• External fragmentation
• Paging
• Hardware support for paging
• Internal fragmentation

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

19
USE OF BASE AND LIMIT REGISTER

20
HARDWARE SUPPORT

21
I/O PROTECTION

• All I/O instructions are privileged instructions.


• 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).

22
USE OF A SYSTEM CALL TO PERFORM I/O

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

24
OS COMPONENTS

• Process management
• Main memory management
• Secondary storage management
• I/O system management
• File management
• Protection system
• Networking
• Command-line interpreter (shells)

25
OPERATING SYSTEM SERVICES

Services for user and users of programs:


• Program execution
• I/O Operations
• File System Manipulation
• Communications between processes/users
• Error detection and handling
Services for efficient system operation:
• Resource management
• Accounting
• Protection

26
ANY QUESTIONS ?

27

You might also like