Uploaded by Haylemichael Abate

OS chap-1

advertisement
INTRODUCTION
What is an Operating system
A program that acts as an intermediary between a user of a computer and
the computer hardware.
A systems program which controls all the computer's resources and
provides a base upon which application programs can be written.
Operating system goals:



Execute user programs and make solving user problems easier.
Make the computer system convenient to use.
Use the computer hardware in an efficient manner.
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).
1
Operating System Functions


Resource allocator - manages and allocates resources.
Control program - controls the execution of user programs and operation
of I/O devices.
 Kernel - the one program running at all times (all else being
application programs).
o
is responsible for low-level tasks such as
• disk management,
• memory management,
• task management, etc.
o
Provides an interface between the user and the hardware
components of the system.
o
When a process makes a request to the Kernel, then it is
called System Call.
Early Systems - bare machine (early 1950s) - First Generation.




Structure
o Large machines run from console
o Single user system
o Programmer/User as operator
o Paper tape or punched cards
Early Software
o Assemblers
o Loaders
o Linkers
o Libraries of common subroutines
o Compilers
o Device drivers
Secure
Inefficient use of expensive resources
o Low CPU utilization
o Significant amount of setup time
Simple Batch Systems - Second Generation.





Use an operator (somebody to work the machine)
Add a card reader (a device to read programs written on punched cards)
Reduce setup time by batching similar jobs
Automatic job sequencing - automatically transfers control from one
job to another. First rudimentary operating system.
Resident monitor
o initial control in monitor
o control transfers to job
2
o
when job completes control transfers back to monitor
Resident Monitor

The Resident Monitor is a code which runs on Bare Machine.

Its acts like an operating system which controls everything inside a processor and performs all
the functions.

The Resident Monitor is thus also known as the Job Sequencer because like the Operating
system, it also sequences the jobs and sends it to the processor for execution.

After the jobs are scheduled, the Resident Monitor loads the Programs one by one into the main
memory according to their sequence.

The advantage of using a Resident Monitor over an Operating System is that there is no gap or lag
between the program executions. So, the processing is faster in the Resident Monitors.
Spooling - overlap the I/O of one job with the computation of another job.
Multiprogramming and Time Sharing- Third
Generation Multiprogramming

Several jobs are kept in main memory at the same time, and the CPU is
shared between them. Each job is called a process.
OS Features Needed for Multiprogramming




I/O routine supplied by the system.
Memory management - the system must allocate the memory to several jobs.
CPU scheduling - the system must choose among several jobs ready to run.
Allocation of devices.
Time-Sharing Systems- Interactive Computing



Most efficient for many users to share a large computer.
The CPU is shared between several processes.
Each process belongs to a user and I/O is to/from a separate terminal for
each user.
3

On-line file system must be available for users to access data and code.
Personal-Computer Systems - Fourth Generation




Personal computers - computer system dedicated to a single user.
I/O devices - keyboards, mice, display screens, small printers.
User convenience and responsiveness.
Can adopt technology developed for larger operating systems; often
individuals have sole use of computer and do not need advanced CPU
utilization or protection features.
Parallel Systems - multiprocessor systems with more than one CPU in
close communication.

Tightly coupled system - processors share memory and a clock;
communication usually takes place through the shared memory.
 Advantages of parallel systems:
o Increased throughput
o Economical
o Increased reliability
 Symmetric multiprocessing
o Each processor runs an identical copy of the operating system.
o Many processes can run at once without performance deterioration.
 Asymmetric multiprocessing
o Each processor is assigned a specific task; master processor schedules
and allocates work to slave processors.
o More common in extremely large systems.
Distributed Systems - distribute the computation among several
physical processors.


Loosely coupled system - each processor has its own local memory;
processors communicate with one another through various communication
lines, such as high-speed networks.
Advantages of distributed systems:
o Resource sharing
o Computation speed up - load sharing
o Reliability
o Communication
Real-Time 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.
OS must be able to respond very quickly.
4
COMPUTER-SYSTEM STRUCTURES
Computer-System Operation







I/O devices and the CPU can operate concurrently.
Each device controller is in charge of a particular device type.
Each device controller has a local buffer.
CPU moves data from/to main memory to/from the local buffers.
I/O is from the device to local buffer of controller.
Device controller informs CPU that it has finished its operation by causing
an interrupt.
Buffer is a region of a physical memory storage used to temporarily store data while it is being
moved from one place to another
Interrupts
are signals sent to the CPU by external devices, normally I/O devices.
They tell the CPU to stop its current activities and execute the appropriate part of
the operating system.
Types
1. Hardware - Asynchronous
Device informs CPU that something has happened e.g. a key has been pressed
on the keyboard.
2. Hardware - Synchronous
CPU has tried to do something that has caused the interrupt. e.g. tried to read
from an invalid memory location. (not always a problem, it may mean that that
page is on disk needs to be fetched). Often called an Exception or Trap.
3. Software
CPU asked for the interrupt to happen. e.g. to perform an OS Call. Often called a
Trap.
Interrupt Handling

Interrupt handling is a very important part of the OS.
5



The operating system must preserve the state of the CPU by storing all registers.
Determine which type of interrupt has occurred:
o polling - ask each device if it caused the interrupt.
o vectored interrupt system - device identifies itself when it causes
the interrupt.
Separate segments of code determine what action should be taken for each
type of interrupt.
I/O Calls
Blocking I/O


User program requests I/O, control returns to user program only upon
I/O completion. i.e., Control does not return to the application
until the I/O is complete.
o CPU may be allocated to another process.
alled synchronous programming.
Non-Blocking I/O


After I/O starts, control returns to user program without waiting for
I/O completion.
asynchronous programming
Direct Memory Access (DMA) Structure



Used for high-speed I/O devices able to transmit information at close to
memory speeds.
Device controller transfers blocks of data from buffer storage directly to
main memory without CPU intervention.
Only one interrupt is generated per block, rather than the one interrupt per byte.
Storage Structure



Main memory - only large storage media that the CPU can access directly.
Secondary storage - extension of main memory that provides large nonvolatile storage capacity.
Magnetic disks
o Disk surface is logically divided into tracks, which are subdivided
6
o
into sectors.
The disk controller determines the logical interaction between the
device and the computer.
Storage Hierarchy


Storage systems can be organized in a hierarchy:
o speed
o cost
o volatility
Most programs make accesses to memory which are localised
o in time
i.e. the program spends a lot of time executing short sections of code.
o

in space
i.e. the program reads and writes to certain memory locations a lot;
these locations tend to be close together.
Caching - copying information into faster storage system; main memory can
be viewed as a fast cache for secondary memory.
Hardware Protection




Dual-Mode Operation
I/O Protection
Memory Protection
CPU Protection
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.
o
o


User mode
- execution done on behalf of a user.
Monitor mode (also supervisor mode or system mode)
- execution done on behalf of operating system.
Mode bit added to computer hardware (in CPU flags) to indicate the current
mode: monitor (0) or user (1).
When an interrupt or fault occurs hardware switches to monitor mode
7


Certain Privileged instructions can be issued only in monitor mode.
Some CPUs have more complex protection mechanisms with many
levels of protection (sometimes called rings).
I/O Protection




when we ensuring the I/O protection then some cases will never have occurred in the system as:
o Termination I/O of other process
o View I/O of other process
o Giving priority to a particular process I/O
We know that when an application process wants to access any I/O device it should be done
through system call so that the Operating system will monitor the task.
All I/O instructions are privileged instructions.
Must ensure that a user program could never gain control of the
computer in monitor mode
Memory Protection



Must provide memory protection at least for the interrupt vector and the
interrupt service routines.
In order to have memory protection, add two registers that determine the
range of legal addresses a program may access:
o base register - holds the smallest legal physical memory address.
o limit register - contains the size of the range.
Memory outside the defined range is protected.
8

Protection hardware

When executing in monitor mode, the operating system has unrestricted
access to both monitor and users' memory.
The load instructions for the base and limit registers are privileged instructions.
In practice, memory protection is much more complicated than this. A
device called a Memory Management Unit (MMU) controls access to
memory.


CPU Protection - how does the OS stay in control?





Timer - interrupts computer after specified period to ensure operating
system maintains control.
o Timer is decremented every clock tick.
o When timer reaches the value 0, an interrupt occurs.
Timer used to implement multiprogramming.
Timer also used to compute the current time.
Load-timer is a privileged instruction.
User programs cannot disable interrupts.
9
General-System Architecture


Given that I/O instructions are privileged, how does the user program perform I/O?
System call - the method used by a process to request action by the
operating system.
o Usually takes the form of a trap (software interrupt).
o Control passes through an interrupt vector to a service routine in the
OS, and the mode bit is automatically set to supervisor mode.
o The OS verifies that the parameters are correct and legal, executes
the request, and returns control to the instruction following the
system call.
There are four types of operating systems −




Real-time operating system
Single-User/Single-Tasking operating system
Single-User/Multitasking operating system
Multi-User/Multitasking operating system
Real-time operating system
Real-time operating system is designed to run real-time applications. It can be both single- and
multi-tasking. Examples include Abbasi, AMX RTOS, etc.
Advantages

It works very fast.

It is time saving, as it need not be loaded from memory.

Since it is very small, it occupies less space in memory.
Single-User/Single-Tasking OS
An operating system that allows a single user to perform only one task at a time is called a SingleUser Single-Tasking Operating System. Functions like printing a document, downloading images,
etc., can be performed only one at a time. Examples include MS-DOS, Palm OS, etc.
Advantages

This operating system occupies less space in memory.
Disadvantages

It can perform only a single task at a time.
10
Single-User/Multitasking OS
An operating system that allows a single user to perform more than one task at a time is called
Single-User Multitasking Operating System. Examples include Microsoft Windows and Macintosh
OS.
Advantages

It is time saving as it performs multiple tasks at a time yielding high productivity.
Disadvantages

This operating system is highly complex and occupies more space.
Multiuser/Multitasking OS
It is an operating system that permits several users to utilize the programs that are concurrently
running on a single network server. The single network server is termed as "Terminal server".
"Terminal client" is a software that supports user sessions. Examples include UNIX, MVS, etc.
11
Advantages

It is highly productive as it performs multiple tasks at a time.

It is time saving as we don’t have to make changes in many desktops, instead can make
changes only to the server.
Disadvantages

If the connection to the server is broken, user cannot perform any task on the client as it is
connected to that server.
12
Download