You are on page 1of 45

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.
O.S.@ K.I.T.

2/19/2014

Computer System
Fundamental features of computer systems that are
important to an OS
1)
The Central Processing Unit (CPU)
2)
Memory hierarchy
3)
I/O organization
4)
Interrupt structure

O.S.@ K.I.T.

2/19/2014

Model of a Computer System

O.S.@ K.I.T.

2/19/2014

1)The Central Processing Unit (CPU)

1)

CPU contains two kinds of registers


General purpose registers
Also called program-accessible registers
Hold data, addresses, index values, or the stack pointer during
execution of a program

1)

Control registers
Contain information that controls or influences operation of the CPU
Set of control registers is called the program status word (PSW)
O.S.@ K.I.T.

2/19/2014

The Central Processing Unit (CPU)


(continued)

The program status word (PSW) is a collection of


control registers in the systems:

O.S.@ K.I.T.

2/19/2014

The Central Processing Unit (CPU)


(continued)

1)

CPU can operate in two modes


Kernel mode

2)

Can execute privileged instructions


OS puts CPU in kernel mode when it is executing instructions in
the kernel

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
O.S.@ K.I.T.

2/19/2014

The Central Processing Unit (CPU)


(continued)

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
O.S.@ K.I.T.

2/19/2014

2)Memory hierarchy

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
O.S.@ K.I.T.

2/19/2014

Memory hierarchy (continued)

The MMU translate each memory address


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

MMU
O.S.@ K.I.T.

2/19/2014

Memory hierarchy (continued)

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

MMU
O.S.@ K.I.T.

2/19/2014

Memory hierarchy (continued)

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

O.S.@ K.I.T.

2/19/2014

O.S.@ K.I.T.

2/19/2014

3)Input/Output Subsystem

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)
2)
3)

Programmed I/O
Interrupt I/O
Direct memory access (DMA)
O.S.@ K.I.T.

2/19/2014

4)Interrupts

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
O.S.@ K.I.T.

2/19/2014

Classes of Interrupts

O.S.@ K.I.T.

2/19/2014

OS Interaction with the Computer and


User Programs
1)
2)
3)

Controlling Execution of Programs


Interrupt Processing
System Calls

O.S.@ K.I.T.

2/19/2014

1)Controlling Execution of Programs

When user program starts, PSW should contain:


1)
2)
3)
4)

Program counter (PC) field contains the address of the


first instruction in the program
Mode (M) field, set to user mode (1)
Memory protection information (MPI) field contains
start address in memory and size of program
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
O.S.@ K.I.T. 2/19/2014

2)Interrupt Processing

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
O.S.@ K.I.T.

2/19/2014

Interrupt Processing (continued)


Nested interrupt Processing
Two approaches for nested interrupt processing :

1.
2.

Disable nested interrupts through masking


Service more critical interrupts in a nested manner interruptible
kernel

O.S.@ K.I.T.

2/19/2014

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

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
O.S.@ K.I.T.

2/19/2014

Efficiency, System Performance, and


User Convenience

1)
2)

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
Nature of computation in an OS
Measuring Efficiency, System Performance, and
User Convenience
O.S.@ K.I.T.

2/19/2014

1)Nature of computation in an OS

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

O.S.@ K.I.T.

2/19/2014

2)Measuring Efficiency, System


Performance, and User Convenience

Two of the fundamental goals of an OS:


Efficiency
Of

User

of use

a resource

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
O.S.@ K.I.T.

2/19/2014

Measuring Efficiency, System Performance,


and User Convenience (continued)

O.S.@ K.I.T.

2/19/2014

Classes of Operating Systems

O.S.@ K.I.T.

2/19/2014

O.S.@ K.I.T.

2/19/2014

Batch Processing Systems

Batch: sequence of user jobs formed for processing by the


OS
Batching kernel initiates processing of jobs without
requiring computer operators intervention
Control statements used to protect against interference
between jobs

O.S.@ K.I.T.

2/19/2014

2/19/2014

O.S.@ K.I.T.

Multiprogramming Systems

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

O.S.@ K.I.T.

2/19/2014

Multiprogramming Systems (continued)

O.S.@ KIT

2/19/2014

Multiprogramming Systems (continued)

O.S.@ K.I.T.

2/19/2014

Priority of Programs

O.S.@ KIT

2/19/2014

Priority of Programs (continued)


In multiprogramming environments, an I/O-bound program should have a higher
priority than a CPU-bound program.

O.S.@ K.I.T.

2/19/2014

Time-Sharing Systems

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

O.S.@ K.I.T.

2/19/2014

Time-Sharing Systems (continued)

O.S.@ K.I.T.
2/19/2014

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
2/19/2014

O.S.@ K.I.T.

Swapping of Programs

Swapping allows the kernel to service more processes


than can fit into the memory
Kernel

performs swap-out and swap-in operations


O.S.@ K.I.T.

2/19/2014

Real-Time Operating Systems

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

O.S.@ K.I.T.
2/19/2014

Hard and Soft Real-Time Systems

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
Meets

E.g.,

guarantee that it will be able to meet it


requirements in a probabilistic manner

multimedia applications
O.S.@ K.I.T.
2/19/2014

Distributed Operating Systems

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

O.S.@ K.I.T.
2/19/2014

Distributed Operating Systems


(continued)

Special Techniques of Distributed


Operating Systems

Summary

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

O.S.@ K.I.T.
2/19/2014

Summary (continued)

Evolution (continued)
Real-time

operating systems

Priority-based scheduling and deadline-aware scheduling

Distributed

operating system

Lets programs share resources across network

O.S.@ K.I.T.
2/19/2014

You might also like