Introduction to Operating
System
Absence of operating system
Presence of Operating System
Abstract view of components of a computer
system
Role of OS from user perspective
• From single user end, OS
A computer system consist of must max the work
The hardware • Users connected to servers
The CPU, Memory, I/O devices or in a network, OS must
max resource utilization
The operating system
The application program
Word Processor, Spreadsheet, compilers, web browsers
The users
Role of OS from system
People, Machines, other computers perspective
• Should execute user
program
• Control I/O devices
What is Operating System?
A large and complex software component for the operation
and control of the computer system.
It acts as an intermediary between a user and the computer
system.
A provider of services to user programs
A huge resource manager
Defining Operating System
a p p lic a tio ns
utilitie s so ftwa re
sy ste m s
so ftw a re
Op e ra ting syste m
ha rd w a re
de vic e de vic e ... de vic e
c o m p o ne nts CPU
m e m o ry
“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.”
Kernel – the one program running at all times on the
computer
Control program – controls the execution of user programs
and operations of I/O devices .
Resource allocator – manages and allocates resources.
For multiple users, OS creates an environment wherein users get a
feel of accessing all computing resources “simultaneously”: CPU
time, Memory (RAM, swap, working set, virtual,..), File system
(storage space), I/O devices (Display, Printers, Mouse,..), Clock
Why we need OS?
Convenience: An OS makes a computer more convenient to use.
Efficiency: An OS allows the computer system resources to be used
in an efficient manner.
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 at the same time interfering with service.
Types of Operating system
Batch Processing operating system
Time sharing or Multi user operating system
Multi Tasking operating system
Real TIME Operating system
Multi Processor Operating system
Embedded Operating system
Common Operating System
Windows family of operating systems developed by Microsoft
The Macintosh operating systems developed by Apple
The UNIX family of operating systems (Developed by a whole
history of individuals, corporations and collaborators)
Other operating systems available for special-purpose applications
specializations for mainframes
Robotics
Manufacturing
Real-time control systems
Mobile
Operating System Services
User Operating System Services
Operating System Services for System
User Operating System Services
1. Program execution – The OS must be capable to load a program into memory
and to run it.
2. I/O operations – Since user programs cannot execute I/O operations directly, the
OS must provide some means to perform I/O.
3. File-system manipulation – OS must support the programs to read, write,
create, and delete files. Also search files, list file information and include
permission management of files & directories.
4. Communications – OS should perform exchange of information between
processes executing either on the same computer or on different systems tied
together by a network.
5. Error detection – OS needs to be constantly aware of possible errors (memory
error, power failure, I/O error, program error). OS should take appropriate action
and ensure correct & consistent computing.
Operating System Services for System
Resource allocation
Accounting
Protection and security
OS Components
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:-
1. Process Management
2. Main Memory Management
3. File Management
4. I/O System Management
5. Secondary Management
6. Distributed System
7. Protection and Security
1. Process Management
A program in execution is a Process.
Eg. Compiler, word-processing program, sending output to printer.
A process is the unit of work in a system.
A system = Operating system processes + User processes.
[ Executing concurrently by multiplexing CPU ]
To accomplish its task, a process needs certain resources, including CPU time, memory,
files, and I/O devices.
The OS is responsible for following activities in concern with Process Management.
Process creation and deletion.
Process Scheduling (priority, time management, . . . )
Process suspension and resumption.
Mechanisms for process synchronization and communication.
Mechanisms for deadlock handling.
2. Main Memory Management
Memory is a large array of words or bytes, each with its own address.
It is a quickly accessible data shared by CPU and I/O devices.
The OS is responsible for following activities in concern with memory
management:
Keep track of which parts of memory are currently being used and by whom.
Decide which processes to load when memory space becomes available.
Allocate and deallocate memory space as needed.
Keep track of who's using what memory.
Movement of process memory to/from secondary storage.
Memory management is the functionality of an operating system which handles or
manages primary memory. Memory management keeps track of each and every memory
location either it is allocated to some process or it is free. It checks how much memory is
to be allocated to processes. It decides which process will get memory at what time. It
tracks whenever some memory gets freed or unallocated and correspondingly it updates
the status.
Memory management provides protection by using two registers, a base register and a
limit register. The base register holds the smallest legal physical memory address and the
limit register specifies the size of the range. For example, if the base register holds 300000
and the limit register is 1209000, then the program can legally access all addresses from
300000 through 411999.
3. File Management
A file is a collection of related information defined by its creator.
Commonly, files represent programs files (both source and object forms) and data files
(numeric, alphabetic, alphanumeric or binary) .
Files are normally organized into directories to make them easier to use.
OS performs file management by managing devices ( Magnetic disk, optical disk,
magnetic tape) that control them.
The OS is responsible for following activities in concern with file management:
File creation and deletion.
Directory creation and deletion to organize files.
Support of primitives for accessing and manipulating files and directories
File security
Mapping files onto secondary storage
Backing up files on stable (nonvolatile) storage media.
4. I/O System Management
The I/O system consists of several components:
Drivers for specific hardware devices
A general device-driver interface
Buffering, caching and spooling system
The OS is responsible for following activities in concern with I/O management:
Servicing requests to use IO devices
Sharing devices between users and processes
Hiding device peculiarities using device drivers
Optimizing device performance
IO error handling
Buffering and caching
5. Secondary Storage Management
Secondary storage back ups main memory.
Secondary storage is required since:
Main memory is too small to accommodate all data & programs
Also the data in it is lost when power is lost.
The OS is responsible for following activities in concern with Secondary management:
Managing Disks, tapes, optical, ...
Free space management ( paging/swapping )
Storage allocation ( what data goes where on disk )
Disk scheduling
Distributed System
A distributed system is a collection computer systems that are connected through a
communication network.
Distributed system provide users with the access to various resources that the system
maintains.
This increases computation speed, functionality, data availability and reliability.
The OS is responsible for following activities in concern with Distributed System:
Communication system between distributed processors.
Getting information about files/processes/etc. on a remote machine.
Can use either a message passing or a shared memory model.
Protection and Security
Protection refers to a mechanism for internally controlling access of programs, processes,
and users to system and user resources.
Protection can improve reliability by detecting latent errors at the interfaces between
component subsystems.
The OS is responsible for following activities in concern with Protection and Security:
Distinguish between authorized and unauthorized usage.
Specify the controls to be imposed.
****
Operating System Structure
Structuring tells how an OS is put together.
A proper structure is essential for proper functioning of OS.
Structuring means partitioning the task into small components.
Each of these modules will be a well defined portion of the system ,
with carefully defined inputs, outputs & functions.
The interconnection of OS components are leading to following
structures:
Simple structure
Layered Approach
1. Simple Structure
Example of MS-DOS
• This is an inefficient structuring of OS.
• Application programs have a direct
access to basic I/O routines.
• The interfaces and level of functionality
are not well separated.
• Errant or malicious programs can cause
the entire system to crash.
2. Layered Structure
Here OS is divided into pieces that are smaller & appropriate
The operating system is
divided into a number of
layers (levels), each built on
top of lower layers.
The bottom layer is the K
e
hardware; the highest is the r
user interface. n
e
l
2. Layered Structure
Advantages:
Simplicity of construction of OS and its debugging.
OS can retain a proper control over the system and over its applications.
Gives freedom in modifying the OS.
Difficulties:
Involves appropriately defining the various layers.
Each layer adds overhead to the system calls, the net result is that system
takes longer time than a non-layered structure.
System Calls
System calls provide an interface to the services made available by an OS.
System calls are generally available as routines written in C and C++.
Eg.
copy
Source File Destination File
System Calls invoked?
System Calls Print message to console and terminate
abnormally
Source File Destination File
System calls invoked are: a. No i/p file of that name exists
b. File access protection
Possible a. O/p file of that name exists
1. Open the input file
b. File access protection
2. Create the output file Errors
3. Loop
Program may abort, or may i. Read from input file Possible a. Hardware failure in read
delete existing file and create b. No more disk space
ii. Write to output file Errors
a new one
4. Write completion message to screen
5. Terminate normally
System Calls
• A system-call interface that serves as the link to system calls made available by the
OS.
• The User needs to know nothing about how the system call is implemented or what it
does during execution.
• A number is associated with each system call,
and the system-call interface maintains a
table indexed according to these numbers.
The system call interface then
invokes the intended system call
in the operating system kernel
and returns the status of the system
call and any return values.
Types of System Calls
Process control
end, abort
load, execute
create process, terminate process
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
File management
create file, delete file
open, close
read, write, reposition
get file attributes, set file attributes
Types of System Calls
Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
Information maintenance
get time or date, set time or date
get system data, set system data
get process, file, or device attributes
set process, file, or device attributes
Communications
create, delete communication connection
send, receive messages
transfer status information
attach or detach remote devices
Buffering in OS
What is Buffering?A buffer is a region of memory used to temporarily hold data while it
is being moved between two devices or between a device and an application.
Buffering is done for three reasons:
To cope with the speed mismatch between the producer and consumer of a data stream.
Eg:- Modem --------------------------------------------------------------------------->Hard disk
Data transfer
[Slower Device]-------- [Buffer in main memory]----------------- [Fast device]
Accumulate data Write in one operation
To cope between devices that have different data-transfer sizes.
Eg: In Networks, where large data is fragmented in Tx side, the Rx side reassembles these packets
To support “copy semantics” for I/O application.
Output Buffering:- Processor stores data in buffer, O/P device then takes from it
Input Buffering:- Data transferred from I/P channel is buffered, the processor then access
the data from buffer.
Pg.
Types of Buffering in OS
1. Single Buffering When a user process issues an I/O request, the operating system
assigns a buffer in the system portion of main memory to the operation. Input transfers are
made to the system buffer. When the transfer is complete, the process moves the block into
user space and immediately requests another block.
2. Double BufferingAn improvement over single buffering can be done by assigning two
system buffers to operation. A process now transfers data to one buffer while the operating
system empties the other. This technique is known as double buffering or buffer
swapping.
Types of Buffering in OS
3. Circular Buffering Double buffering may be inadequate if the process performs rapid
bursts of I/O. In this case, the problem can be solved by using more than one buffer. When
more than two buffers are used, the collection of buffers is itself referred to as a circular
buffer.
Caching in OS
A Cache is a region of fast memory that holds copies of data.
Where is it needed?
During a process execution, a memory access may take many CPU clock to complete. The
remedy is to add a fast memory between CPU and main memory.
Access to cached copy is more efficient than access to the original data.
Cache are used to store currently running process.
Cache are large enough to store entire tracks at a time.
Spooling
SPOOL Simultaneous Peripheral Operation On-Line
Spool is a buffer that holds output for a device, such as printer, that
cannot accept interleaved data stream.
High speed device transfers the data to the spool. Low speed device
gets the data from the spool.
Spooling can keep both the CPU and the I/O devices working at
much higher rates
Performance of the system is increased.