0% found this document useful (0 votes)
100 views49 pages

VTU 6th Semester ECE Operating System PP

Uploaded by

Krupanand Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views49 pages

VTU 6th Semester ECE Operating System PP

Uploaded by

Krupanand Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 49

OS and the Computer System

 Some OS programs exist permanently in the system area of


the memory to monitor and control activities in the
computer system
 Other programs exist on a disk
and are loaded in the transient
area when needed.

 Remainder of the memory is


occupied by user programs.
Krupananda S, Jetking
Computer System
2

Fundamental features of computer systems that are


important to an OS
1) The Central Processing Unit (CPU)

2) Memory hierarchy

3) Interrupt structure

4) I/O organization

Krupananda S, Jetking
Model of a Computer System
3

Krupananda S, Jetking
1)The Central Processing Unit (CPU)
4
 CPU contains two kinds of registers
1) General purpose registers
Also called program-accessible registers
Hold data, addresses, index values, or the stack pointer during
execution of a program

2) Control registers
Contain information that controls or influences operation of the CPU
Set of control registers is called the program status word (PSW)

Krupananda S, Jetking
The Central Processing Unit (CPU) (continued)
5

 The program status word (PSW) is a collection of


control registers in the systems:

Krupananda S, Jetking
The Central Processing Unit (CPU) (continued)
6

 CPU can operate in two modes


1) Kernel mode
 Can execute privileged instructions
 OS puts CPU in kernel mode when it is executing instructions in the
kernel

2) User mode
 Cannot execute privileged instructions
 OS puts CPU in user mode while executing user programs

• Mode (M) field of PSW contains 0 if CPU is in kernel mode and 1


if it is in user mode
Krupananda S, Jetking
The Central Processing Unit (CPU) (continued)
7

 State of the CPU


 GPRs and PSW contain the information needed to
know what the CPU is doing
 State of the CPU

 Kernel saves state of CPU when it takes away the


CPU from program
 When program is to be resumed, it reloads the saved
CPU state into GPRs and PSW

Krupananda S, Jetking
2)Memory hierarchy
8

 The memory hierarchy provides a large and fast memory,


at a low cost
 It is an arrangement of several memory units with
different access speeds and sizes
 The CPU accesses only the fastest memory; i.e., the cache
 If a required byte is not present in the memory being accessed,
it is loaded there from a slower memory

MMU

Krupananda S, Jetking
Memory hierarchy (continued)
9

 The MMU translate each memory address


generated by the CPU into another address called
the physical memory address

MMU

#Sushanth KJ |Faculty, ECE|BIT, M'lore


Memory hierarchy (continued)
10
 Cache memory holds some instructions and data values
that were recently accessed by the CPU
 Blocks of bytes (pages) are transferred from disk to cache
memory
 Hit ratio(h): what fraction of bytes accessed by the CPU
were found in the cache
=h * Access time of cache memory + (1-h) * (ttra+ Access time
of cache memory )

MMU

Krupananda S, Jetking
Memory hierarchy (continued)
11

 Memory protection is implemented by checking


whether a memory address used by a program lies
outside the memory area allocated to it

 Two control registers used: LBR and UBR


 LBR and UBR registers contained in the memory
protection information (MPI) field of PSW

Krupananda S, Jetking
12

Krupananda S, Jetking
3)Input/Output Subsystem
13

 Involvement of the CPU in I/O operations


 Should be the minimum possible due to imbalance
between CPU and I/O speeds
 CPU should be free to execute instructions while I/O
operations are in progress

 Different I/O modes


1) Programmed I/O
2) Interrupt I/O
3) Direct memory access (DMA)
Krupananda S, Jetking
14

Krupananda S, Jetking
4)Interrupts
15

 An interrupt signals the occurrence of an event to the CPU


 The CPU is diverted to execution of an OS routine
 Interrupt action saves CPU state and loads new contents
into the PSW and GPRs
 CPU starts executing instructions of an interrupt servicing
routine (ISR) in the kernel

 Different classes of interrupts convey occurrence of


different kinds of events
Krupananda S, Jetking
Classes of Interrupts
16

Krupananda S, Jetking
17

 OS Interaction with the Computer and


User Programs
 Efficiency, System Performance, and User
Convenience
 Classes of Operating Systems

Krupananda S, Jetking
OS Interaction with the Computer and
User Programs
18

1) Controlling Execution of Programs


2) Interrupt Processing
3) System Calls
 Programs invoke the services of the OS through
software interrupts
 The method to cause a software interrupt is known as a
system call

Krupananda S, Jetking
1)Controlling Execution of
19
Programs
 When user program starts, PSW should contain:
1) Program counter (PC) field contains the address of the
first instruction in the program
2) Mode (M) field, set to user mode (1)
3) Memory protection information (MPI) field contains
start address in memory and size of program
4) Interrupt mask (IM) field, set to enable all interrupts
 When program is interrupted, CPU state(PSW
and GPRs) are saved in the program table
 When program is resumed, its CPU state is

restored Krupananda S, Jetking


2)Interrupt Processing
20

 Context save saves context of the CPU


state so that the program that was being
executed at the time of the interrupt can
be resumed in future
 Context consists of CPU state and
information concerning memory and
resources used by the program
 The scheduling routine selects a program
for execution

Krupananda S, Jetking
Interrupt Processing (continued)
21
Nested interrupt Processing
Two approaches for nested interrupt processing :
1. Disable nested interrupts through masking
2. Service more critical interrupts in a nested manner interruptible
kernel

Krupananda S, Jetking
3)System Calls
22

 A system call is a request made by a program through a


special instruction called a `software interrupt’ instruction
<SI_instrn> <int_code>
 The software interrupt is a program interrupt
 The operand of the software interrupt instruction indicates
what kind of request is being made by a program
Efficiency, System Performance, and User
Convenience
23

 A computing environment consists of a computer


system, its interfaces with other systems, and the
services provided by its operating system to its
users and their programs
1) Nature of computation in an OS
2) Measuring Efficiency, System Performance, and
User Convenience
1)Nature of computation in an OS
24

 Noninteractive Computing Environments


 OS focuses on efficient use of resources
 Computations in form of program or job
 Interactive Computing Environments
 OS focuses on reducing average amount of time
required to implement an interaction between a user
and his computation
 Execution of a program is called a process
Nature of computation in an OS (continued)
25
2)Measuring Efficiency, System Performance, and
User Convenience
26

 Two of the fundamental goals of an OS:


 Efficiency of use
 Of a resource
 User convenience
 Measurable aspect: User service
 Turnaround time
 Response time
 To a system administrator, performance of a system in
its environment is more important
 Typically measured as throughput
Measuring Efficiency, System Performance, and User
Convenience (continued)
27
Classes of Operating Systems
28
Batch Processing Systems
29

 Batch: sequence of user jobs formed for processing by the


OS
 Batching kernel initiates processing of jobs without
requiring computer operator’s intervention

 Control statements used to protect against interference


between jobs
 Command interpreter read a card when currently
executing program in job wanted the next card
30
Multiprogramming Systems
31

 Provide efficient resource utilization in a noninteractive


environment
 Uses DMA mode of I/O
 Can perform I/O operations of some program(s) while using
the CPU to execute some other program
 Makes efficient use of both the CPU and I/O devices
 Turnaround time of a program is the appropriate measure
of user service in these systems
Multiprogramming Systems (continued)
32
Multiprogramming Systems (continued)
33
Multiprogramming Systems
(continued)
34

 An appropriate measure of performance of a


multiprogramming OS is throughput
 Ratio of the number of programs processed and the total time taken
to process them
 OS keeps enough programs in memory at all times, so that
CPU and I/O devices are not idle
 Degree of multiprogramming: number of programs
 Uses an appropriate program mix of CPU-bound programs and I/O-
bound programs
 Assigns appropriate priorities to CPU-bound and I/O-bound
programs
Priority of Programs
35
Priority of Programs (continued)
36 In multiprogramming environments, an I/O-bound program should have a higher
priority than a CPU-bound program.

#Sushanth KJ |Faculty, ECE|BIT, M'lore


Performance of
Multiprogramming systems
37

• How to improve performance?

#Sushanth KJ |Faculty, ECE|BIT, M'lore


Performance of
Multiprogramming systems (continued)
38

When an appropriate program mix is maintained, an increase in the degree of


multiprogramming would result in an increase in throughput.
Time-Sharing Systems
39

 Provide a quick response to user subrequests


 Round-robin scheduling with time-slicing
 Kernel maintains a scheduling queue
 If time slice (δ) elapses before process completes servicing
of a subrequest, kernel preempts it, moves it to end of
queue, and schedules another process
 Implemented through a timer interrupt
Time-Sharing Systems (continued)
40

#Sushanth KJ |Faculty, ECE|BIT, M'lore


Time-Sharing Systems (continued)
 Response time (rt): measure of user service
 If processing of a subrequest requires δ CPU seconds
rt = n × (δ + σ)
η = δ / (δ + σ)
where η: CPU efficiency,
σ: scheduling overhead,
n: number of users using system,
δ: time required to complete a subrequest
 Actual response time would be different because
 Some users may be inactive
 Some programs may require > δ CPU seconds
41
Swapping of Programs
42

 Swapping allows the kernel to service more processes


than can fit into the memory
 Improve system throughput and response times of processes
 Kernel performs swap-out and swap-in operations
Real-Time Operating Systems
43

 In real-time applications, users need computer to perform


some actions in a timely manner
 To control activities in an external system, or to participate in
them
 Timeliness depends on time constraints

 If application takes too long to respond to an activity, a


failure can occur in the external system
 Response requirement
 Deadline: time by which action should be performed
Hard and Soft Real-Time Systems
44

 A hard real-time system meets response


requirements under all conditions
 It is typically dedicated to processing real-time
applications
 A soft real-time system makes best effort to meet
response requirement of a real-time application
 Cannot guarantee that it will be able to meet it
 Meets requirements in a probabilistic manner
 E.g., multimedia applications
Distributed Operating Systems
45

 A distributed computer system consists of several


individual computer systems connected through a
network
 Each computer system could be a PC, a multiprocessor
system, or a cluster
 Many resources of a kind exist in system
 This feature is used to provide the benefits summarized in Table
3.8
 Handling network or individual computers’ failure requires
special techniques
 Users must use special techniques to access resources over
the network
Distributed Operating Systems (continued)
46
Special Techniques of Distributed Operating
Systems
47
Summary
48

 A computing environment consists of a computer


system, its interfaces with other systems, and the
services provided by its OS to users and programs
 Evolved with advances in computer technology:
 Batch processing systems
 Multiprogramming operating system
 Priority-based scheduling
 Time-sharing operating systems
 Round-robin scheduling with time-slicing
Summary (continued)
49

 Evolution (continued)
 Real-time operating systems
 Priority-based scheduling and deadline-aware scheduling
 Distributed operating system
 Let's programs share resources across network

You might also like