You are on page 1of 23

UNIT-4

I/O organization
Interfacing I/O Devices with CPUProgrammed I/O, Interrupt driven I/O,
DMA controlled I/O
OPERATING SYSTEM SUPPORT
Overview, Scheduling-FCFS, SJF,
Priority, Mutual exclusion, Memory
management.

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
4. Users (people, machines, other computers).

Operating Systems
Just like a resource manager
Should know
a.What are the resources in the computer system
b.What is meant by management of all these systems
Resources:
1.CPU
2.Main Memory:Question of management comes.Again the
responsibilty of OS
3.Secondary storage
4.I/O Devices
responsible of the OS is to manage the above resources.
CPU or Process management:
Waiting Time
Turn around Time

What is an Operating
System?
A program that acts
as an intermediary between a
user of a computer and the computer hardware.
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.
Resource allocator manages and allocates
resources.
Control program controls the execution of user
programs and operations of I/O devices .

Definition of Operating System:

An Operating system is a program that controls the


execution of application programs and acts as an
interface between the user of a computer and the
computer hardware.
A more common definition is that the operating
system is the one program running at all times
on the computer with all else being applications
programs.
An Operating system is concerned with the
allocation of resources and services, such as
memory, processors, devices and information.
The Operating System correspondingly includes
programs to manage these resources, such as a
traffic controller, a scheduler, memory management
module, I/O programs, and a file system.

An OS is a Resource
Multiple users Allocator
get all computing resources
simultaneously:

Cpu time
Memory (ram, swap, working set, virtual,..)
File system (storage space)
I/O devices (display, printers, mouse,..)
Clock

The OS should give every user the illusion that


she is getting all resources to herself (not
sharing!)
loop forever {
run the process for a while.
stop process and save its state.
load state of another process.
}

Functions of Operating System

Operating system performs three functions:


1. Convenience: An OS makes a computer
more convenient to use.
2. Efficiency: An OS allows the computer
system resources to be used in an
efficient manner.
3. Ability to Evolve: An OS should be
constructed in such a way as to permit
the effective development, testing and
introduction of new system functions
without interfering with service.

Abstract View of System Components

OS is designed to serve two basic purposes :


1. It controls the allocation and use of the
computing systems resources among the
various user and tasks.
2. It provides an interface between the
computer hardware and the programmer
that simplifies and makes feasible for coding,
creation, debugging of application programs.

The operating system must support the following tasks.


The tasks are :
1. Provides the facilities to create, modification of
program and data files using an editor.
2. Access to the compiler for translating the user
program from high level language to machine
language.
3. Provide a loader program to move the compiled
program code to the computers memory for execution.
4. Provide routines that handle the details of I/O
programming

Operating System Services

An operating system provides services to programs and to


the users of those programs.
It is provided by one environment for the execution of
programs.
The services provided by one operating system is different
than other operating system.
Operating system makes the programming task easier.
The common service provided by the operating system is
listed below.
1. Program execution
2. I/O operation
3. File system manipulation
4. Communications
5. Error detection

1. Program execution: Operating system loads a program


into memory and executes the program. The program
must be able to end its execution.
2. I/O Operation : I/O means any file or any specific I/O
device. Program may require any I/O device while running.
So operating system must provide the required I/O.
3. File system manipulation : Program needs to read a
file or write a file. The operating system gives the
permission to the program for operation on file.
4. Communication : Data transfer between two processes
is required for some time. The both processes are on the
one computer or on different computer but connected
through computer network.
5. Error detection : error may occur in CPU, in I/O devices
or in the memory hardware. The operating system
constantly needs to be aware of possible errors. It should
take the appropriate action to ensure correct and
consistent computing.

Operating system with multiple users


provides following services.
1. Resource Allocation
2. Accounting
3. Protection

Resource Allocation :

If there are more than one user or jobs


running at the same time, then resources
must be allocated to each of them.
Operating system manages different types of
resources require special allocation code, i.e.
main memory, CPU cycles and file storage.
For allocating CPU, CPU scheduling algorithms
are used for better utilization of CPU.
CPU scheduling routines consider the speed
of the CPU, number of available registers and
other required factors.

Accounting :

Logs of each user must be kept.


It is also necessary to keep record of
which user how much and what kinds
of computer resources. This log is
used for accounting purposes.

Protection

Protection involves ensuring that all access to


system resources is controlled.
Security starts with each user having to
authenticate to the system, usually by means of a
password.
External I/O devices must be also protected from
invalid access attempts.
In protection, all the access to the resources is
controlled.
In multiprocessor environment, it is possible that,
one process to interface with the other, or with
the operating system, so protection is required.

Operating System
Components
Modern operating systems share the goal of
supporting the system components. The
system components are :
1. Process Management
2. Main Memory Management
3. File Management
4. Secondary Storage Management
5. I/O System Management
6. Networking
7. Protection System

Scheduling System
A scheduling system allows one process to
use the CPU while another is waiting for
I/O, thereby making full use of otherwise
lost CPU cycles.
The challenge is to make the overall
system as "efficient" and "fair" as
possible, subject to varying and often
dynamic conditions, and where "efficient"
and "fair" are somewhat subjective terms,
often subject to shifting priority policies.

CPU Scheduler

Whenever the CPU becomes idle, it is


the job of the CPU Scheduler ( a.k.a.
the short-term scheduler ) to select
another process from the ready
queue to run next.
The storage structure for the ready
queue and the algorithm used to
select the next process are not
necessarily a FIFO queue.

Preemptive Scheduling

CPU scheduling decisions take place under one of four conditions:


When a process switches from the running state to the waiting state,
such as for an I/O request or invocation of the wait( ) system call.
When a process switches from the running state to the ready state, for
example in response to an interrupt.
When a process switches from the waiting state to the ready state, say
at completion of I/O or a return from wait( ).
When a process terminates.

For conditions 1 and 4 there is no choice - A new process must be


selected.
For conditions 2 and 3 there is a choice - To either continue
running the current process, or select a different one.
If scheduling takes place only under conditions 1 and 4, the
system is said to benon-preemptive, orcooperative. Under
these conditions, once a process starts running it keeps running,
until it either voluntarily blocks or until it finishes. Otherwise the
system is said to bepreemptive.

Scheduling Criteria

There are several different criteria to consider when trying to


select the "best" scheduling algorithm for a particular situation
and environment, including:
CPU utilization- Ideally the CPU would be busy 100% of the time, so
as to waste 0 CPU cycles.
Throughput- Number of processes completed per unit time.
Turnaround time- Time required for a particular process to complete,
from submission time to completion. (Wall clock time.)
Waiting time- How much time processes spend in the ready queue
waiting their turn to get on the CPU.
(Load average- The average number of processes sitting in the ready queue
waiting their turn to get into the CPU.

Response time- The time taken in an interactive program from the


issuance of a command to thecommenceof a response to that
command.

In general one wants to optimize the average value of a criteria


(Maximize CPU utilization and throughput, and minimize all the
others.) However some times one wants to do something
different, such as to minimize the maximum response time.

You might also like