Computer Network and Infrastructure

Download Report

Transcript Computer Network and Infrastructure

IT206 Operating Systems
Introduction
Dr. E.C. Kulasekere
University of Moratuwa
IT206 Operating Systems
Chapter 1 Expectations






Computer system overview.
Basic elements of ….
Registers.
Functions of an OS related to computer system.
Interrupts.
I/O Communication.
July 18, 2015
IESL-IT Part II - 2004
2
IT206 Operating Systems
What is an Operating System?




Exploits the hardware resources of one or more processors
Provides a set of services to system users
Manages secondary memory and I/O devices
Provides a user friendly environment for computing.
July 18, 2015
IESL-IT Part II - 2004
3
IT206 Operating Systems
Operating System Definitions



Resource allocator – manages and allocates resources.
Control program – controls the execution of user programs and
operations of I/O devices .
Kernel – the one program running at all times (all else being
application programs).
July 18, 2015
IESL-IT Part II - 2004
4
IT206 Operating Systems
What is a Computer System?



Ensemble of hardware components.
Interconnection and communication infrastructure.
Provides functionality to execute programs.
July 18, 2015
IESL-IT Part II - 2004
5
IT206 Operating Systems
Computer System Components
1. Hardware – provides basic computing resources (CPU, memory,
I/O devices).
2. Operating system – controls and coordinates the use of the
hardware among the various application programs for the
various users.
3. Applications programs – define the ways in which the system
resources are used to solve the computing problems of the
users (compilers, database systems, video games, business
programs).
4. Users (people, machines, other computers).
July 18, 2015
IESL-IT Part II - 2004
6
IT206 Operating Systems
Abstract View of Computer System
July 18, 2015
IESL-IT Part II - 2004
7
IT206 Operating Systems
Operating System History
July 18, 2015
IESL-IT Part II - 2004
8
IT206 Operating Systems
Computer Components: Top-Level
July 18, 2015
IESL-IT Part II - 2004
9
IT206 Operating Systems
User Visible Registers



May be referenced by machine language
Available to all programs - application programs and system
programs
Types of registers
 Data
 Address
 Index
 Segment pointer
 Stack pointer
July 18, 2015
IESL-IT Part II - 2004
10
IT206 Operating Systems
User Visible Registers (Cont …)

Address Registers
 Index
 involves adding an index to a base value to get an
address
 Segment pointer
 when memory is divided into segments, memory is
referenced by a segment and an offset
 Stack pointer
 points to top of stack
July 18, 2015
IESL-IT Part II - 2004
11
IT206 Operating Systems
Processor Registers


User-visible registers
 Enable programmer to minimize main-memory references by
optimizing register use
Control and status registers
 Used by processor to control operating of the processor
 Used by operating-system routines to control the execution
of programs
July 18, 2015
IESL-IT Part II - 2004
12
IT206 Operating Systems
Control an Status Registers



Program Counter (PC)
 Contains the address of an instruction to be fetched
Instruction Register (IR)
 Contains the instruction most recently fetched
Program Status Word (PSW)
 condition codes
 Interrupt enable/disable
 Supervisor/user mode
July 18, 2015
IESL-IT Part II - 2004
13
IT206 Operating Systems
Instruction Cycle
July 18, 2015
IESL-IT Part II - 2004
14
IT206 Operating Systems
Fetch and Execute Cycle



The processor fetches the instruction from memory
Program counter (PC) holds address of the instruction to be
fetched next
Program counter is incremented after each fetch
July 18, 2015
IESL-IT Part II - 2004
15
IT206 Operating Systems
Instruction Register


Fetched instruction is placed in the instruction register
Types of instructions
 Processor-memory
 transfer data between processor and memory
 Processor-I/O
 data transferred to or from a peripheral device
 Data processing
 arithmetic or logic operation on data
 Control
 alter sequence of execution
July 18, 2015
IESL-IT Part II - 2004
16
IT206 Operating Systems
Example Execution
July 18, 2015
IESL-IT Part II - 2004
17
IT206 Operating Systems
Direct Memory Access (DMA)




I/O exchanges occur directly with memory
Processor grants I/O module authority to read from or write to
memory
Relieves the processor responsibility for the exchange
Processor is free to do other things
July 18, 2015
IESL-IT Part II - 2004
18
IT206 Operating Systems
Interrupts




An interruption of the normal sequence of execution
Improves processing efficiency
Allows the processor to execute other instructions while an I/O
operation is in progress
A suspension of a process caused by an event external to that
process and performed in such a way that the process can be
resumed
July 18, 2015
IESL-IT Part II - 2004
19
IT206 Operating Systems
Types of Interrupts




Program
 arithmetic overflow
 division by zero
 execute illegal instruction
 reference outside user’s memory space
Timer
I/O
Hardware failure
July 18, 2015
IESL-IT Part II - 2004
20
IT206 Operating Systems
Transfer of Control Via Interrupts
July 18, 2015
IESL-IT Part II - 2004
21
IT206 Operating Systems
Usage of Interrupts



To improve the processing efficiency.
Manage the I/O instruction sequence with non I/O instruction
sequences.
Release resources from a system that is hung up.
July 18, 2015
IESL-IT Part II - 2004
22
IT206 Operating Systems
Interrupt Handler



A program that determines nature of the interrupt and performs
whatever actions are needed
Control is transferred to this program
Generally part of the operating system
July 18, 2015
IESL-IT Part II - 2004
23
IT206 Operating Systems
Interrupt Handler
July 18, 2015
IESL-IT Part II - 2004
24
IT206 Operating Systems
Interrupt Processing
Interrupt
processing
pp. 21-25
July 18, 2015
IESL-IT Part II - 2004
25
IT206 Operating Systems
Interrupt Cycle



Processor checks for interrupts
If no interrupts fetch the next instruction for the current program
If an interrupt is pending, suspend execution of the current
program, and execute the interrupt handler
July 18, 2015
IESL-IT Part II - 2004
26
IT206 Operating Systems
July 18, 2015
IESL-IT Part II - 2004
27
IT206 Operating Systems
Multiple Interrupts

Disable interrupts while an
interrupt is being processed
 Processor ignores any new
interrupt request signals
July 18, 2015
IESL-IT Part II - 2004
28
IT206 Operating Systems
Multiple Interrupts: Sequential Order



Disable interrupts so processor can complete task
Interrupts remain pending until the processor enables interrupts
After interrupt handler routine completes, the processor checks
for additional interrupts
July 18, 2015
IESL-IT Part II - 2004
29
IT206 Operating Systems
Multiple Interrupts: Priorities



Higher priority interrupts cause lower-priority interrupts to wait
Causes a lower-priority interrupt handler to be interrupted
Example when input arrives from communication line, it needs
to be absorbed quickly to make room for more input
July 18, 2015
IESL-IT Part II - 2004
30
IT206 Operating Systems
Rationale Behind Multiprogramming




Interrupts increase the efficiency of the processor by allowing
multiple tasks which may not be sequential in order
However if the time required for I/O operations is longer than the
user operation (this is the true case) the processor will be idle
for a long time.
Multiprogramming which has more than one process in the
memory solves this. Which means multiple user programs are
now available for task switching.
A proper process mix will further enhance the CPU and I/O
hardware utilization.
July 18, 2015
IESL-IT Part II - 2004
31
IT206 Operating Systems
Multiprogramming



Processor has more than one program to execute
The sequence the programs are executed depend on their
relative priority and whether they are waiting for I/O (with
multiple interrupts only)
After an interrupt handler completes, control may not return to
the program that was executing at the time of the interrupt
July 18, 2015
IESL-IT Part II - 2004
32
IT206 Operating Systems
Multiprogrammed Batch System
Several jobs are kept in main memory at the same time, and the
CPU is multiplexed among them.
July 18, 2015
IESL-IT Part II - 2004
33
IT206 Operating Systems
Memory Hierarchy
July 18, 2015
IESL-IT Part II - 2004
34
IT206 Operating Systems
Going Down the Hierarchy




Decreasing cost per bit
Increasing capacity
Increasing access time
Decreasing frequency of access of the memory by the
processor
 locality of reference
July 18, 2015
IESL-IT Part II - 2004
35
IT206 Operating Systems
Disk Cache



A portion of main memory used as a buffer to temporarily to
hold data for the disk
Disk writes are clustered
Some data written out may be referenced again. The data are
retrieved rapidly from the software cache instead of slowly from
disk
July 18, 2015
IESL-IT Part II - 2004
36
IT206 Operating Systems
Cache Memory



Invisible to operating system
Increase the speed of memory
Processor speed is faster than memory speed
July 18, 2015
IESL-IT Part II - 2004
37
IT206 Operating Systems
Cache Memory






Contains a portion of main memory
Processor first checks cache
If not found in cache, the block of memory containing the
needed information is moved to the cache.
2 n addressable words each having a
If the main memory has 2^n
unique n-bit address.
For mapping the main memory is considered to have fixedlength blocks of K words each. That is the main memory has
M=2^n/K such blocks.
Cache consists of C sots of K words each (C<<M).
July 18, 2015
IESL-IT Part II - 2004
38
Cache/Main Memory System
pg. 32 Para 2.
IT206 Operating Systems
Cache Design

Cache size


small caches have a significant impact on
performance
Block size



the unit of data exchanged between cache and main
memory
hit means the information was found in the cache
larger block size more hits until probability of using
newly fetched data becomes less than the probability
of reusing data that has been moved out of cache
July 18, 2015
IESL-IT Part II - 2004
40
IT206 Operating Systems
Cache Design



Mapping function
 determines which cache location the block will occupy
Replacement algorithm
 determines which block to replace
 Least-Recently-Used (LRU) algorithm
Write policy
 When the memory write operation takes place
 Can occur every time block is updated
 Can occur only when block is replaced
 Minimizes memory operations
 Leaves memory in an obsolete
July 18, 2015
IESL-IT Part II - 2004
41
IT206 Operating Systems
Cache Read Operation
Explain the
speed up of a
newly loaded
program using
this figure
July 18, 2015
IESL-IT Part II - 2004
42
IT206 Operating Systems
Techniques for I/O Operations



Programmed I/O
Interrupt-Driven I/O
Direct Memory Access
July 18, 2015
IESL-IT Part II - 2004
43
IT206 Operating Systems
Programmed I/O




A user program coming across an I/O
command will issue a command to the
appropriate module for servicing.
I/O module performs the action, not the
processor
Sets appropriate bits in the I/O status
register and does not interrupt the processor
to alert it has finished processing.
Processor checks status periodically until
operation is complete
July 18, 2015
IESL-IT Part II - 2004
44
IT206 Operating Systems
Problems with Programmed I/O



Processor has to pole the IO module repeatedly checking the
status bit.
The performance of the processor is degraded with the polling
operation.
The processor is responsible for extracting data from main
memory for output and storing data in main memory for input.
July 18, 2015
IESL-IT Part II - 2004
45
IT206 Operating Systems
Interrupt-Driven I/O




Processor is interrupted when I/O module
ready to exchange data
Processor is free to do other work
No needless waiting
Consumes a lot of processor time because
every word read or written passes through
the processor
July 18, 2015
IESL-IT Part II - 2004
46
IT206 Operating Systems
Problems with Interrupt-Driven I/O




Interrupt driven I/O is more efficient than programmed I/O,
however it still requires the active intervention of the processor
for data transfer.
We know that the processor speeds are far greater than the I/O
speeds which will make this intervention of processor
inefficient.
Further there will be an instruction overhead since when the
processor is tied up in managing a I/O transfer, a number of
instructions must be executed for each I/O transfer.
Hence systems such as DMA should be used which does not
use the processor.
July 18, 2015
IESL-IT Part II - 2004
47