Notes os unit 1
Notes os unit 1
Operating Svstem
Operating system is a system program that act as an interface bctween hardware and user.
I t manages system resources.
I t provides a platform on which other application programs are installed.
File System Access: Operating system provides services like read and write files and
directories, search for a given file and directory, access and deny to files and directories
etc to the running program.
Error Detection and Response: Erors may be generated by the user programs or
hardware. Operating system should take the appropriate action to ensure correct and
consistent computing.
Communication: There are many circumstances in which one process needs to exchange
information with another process. Such communication may occur between processes
that are executing on same computer or between processes that are executing on different
computer systems tied together by a computer network communication may be
implemented via shared memory or througn message passing by the operating system.
Components of Computer System
A computer system canbe roughly divided into following four components.
1. Hardware: Basic computing resources like CPU, Memory, I/O Devices etc.
2. Application Programs: Programs that are used to solve users" computing problems e.g.
web browsers, compilers, word processors etc.
3. Operating System: It controls the hardware and coordinates its use among various
application programs for different users. Operating system is similar to government, just like
govermment it provides an environment within which other programs can do useful work.
4.
4. Users: Users perform the computation with the help of application program.
operating systern
computer hardware
JOB: When we combined program, input data and control instruetions together, it is called Job.
JOB
Program
Input Data
Control Instructions
Classification of Operating System
Real Time
Decreasing Memory Size Systemm
Increasine waitingtime Multi Tasking
And Response time
Decreasing speed of CPU
System
Multi Programming
Decreasing CPU utilization
System
Increasing CPU idle time
Simple Batch System
Serial System
Serial System
In this system, Operating System is not needed. Programs interact directly with computer
hardware.
Batch System
Batch means set of jobs with similar need.
I n this system, Operator makes Batch of jobs and loads it into punch card.
Similar types of jobs batch together and execute at a time.
Balch
(u -jobs
Operator
Computer
(Ua
Satch
Advantages
Save time from activities likc loading
compiler.
No manual intervention by user is needed.
Disadvantages
Limited Memory
Interaction of1/0 directly with CPU.
CPU is often idle.
Advantages
High CPU utilization.
Disadvantages
Process scheduling is difficult.
I n this system CPU switches between processes so quickly that it gives an illusion that all
executing at same time.
This system canbe used to handle multiple interactive tasks.
Advantages
High CPU utilization.
Multiprocessing System
A system is called multiprocessing system iftwo or more CPU within a single computer
communicate with each other and share system bus memory and I/O devices.
I t provides true parallel execution of processes.
Advantages:
Increased Throughput: By increasing number of processors, we expect to get more
work done in less time.
Economy of Scale: multiprocessor system can cost less than equivalent multiple single
processor systems.
Increased Reliability: Since work is distributed among several processors; failure of one
processor will not halt the system only slow it down.
Disadvantages
I t is complex system.
Process scheduling is difficult in this system.
1. Hard Real Time System: In hard Real Time system task will be fail if response time
against input is more than specified time.
2 Soft Real Time System: In Soft Real Time system inaccurate result will be found if
Interactive System
Time sharing requires an interactive computer system, which provides direct communication
between the user and the system. The user gives instructions to the Operating System or to a
Multi-user operatingsystem
Multi-user operating system is a computer operating system that allows multiple users on
on it. These
different computerS or terminals to access a single system with one OS
and must be able to properly manage the necessary
programs are often quite complicated
tasks required by the different users connected to it. The users will typically be at terminals
orcomputers that give them access
to the system through a network, as well as other
machines on the system such as printers. Example Ubuntu,Unix
e
Monolithic Kernel
Monolithic means all in one piece.
*In monolithic kemel userservices and kernel services are implemented under same
address space, It increases size of the kernel thus increase size of operating
Example: Linux
system.
Kernel Mode
Monolithic Kernel
System Hardware
Advantage
Execution is faster.
Disadvantages
Size is larger.
Hard to extend.
Hard to port.
More prone to errors and bugs.
Microkernel
I n microkernel, user services and kernel services are implemented in different address space,
therefore it also reduces the size of kernel as well as the size of Operating system.
I n this architecture, only the most important services are present inside kernel and rest of the
operating system services are present inside system application program.
Communication between client process and services running in user address space is established
through message passing thus reduce the speed of execution.
Example: Mach OS
Microkernel
System Hardware
Advantages
Size is smaller.
Easy to extend.
Easy to port.
Less prone to errors and bugs.
Disadvantage
Execution is slower.
Microkernel Monolithic
Parameter
Kernel
Easy | Hard
Extendibility
Easy Hard
Portability
Less More
Error prone
capability
Lavered Kernel
I n layered approach, the OS consists of several layers where each layer has a well
defined functionality and each layer is designed, coded and tested independently.
Lowest layer interacts and deal with underlying hardware and top most layer provides an
interface to the application programs and to the user processes.
*Each layer relies on the serviceofthe layer below it. Communication takes place between
adjacent layers.
Each layer knows what services are provided by the layer above it but the details about
how the services are provided are hidden.
Different layers can be file management layer, process management layer, memory
management layer etc.
uyer N
er itertacs
layer 1
leyer0
hardware
Advantages
Easier to add new feature or change in one layer without affecting the other layer.
make
layers.
Disadvantages
is if no of layers is more.
Overhead incurred to maintain more,
cause low system performance.
are not properly divided it may
I f functionality of layers
Reentrant Kernel
A reentrant kernel is one that consists of executable code stored in memory such that
several processes can use this code at same time without hindering the working of other
processes.
Thus in reentrant kernel several processes may be executed in kernel mode at same time.
Since multipleconcurrent processes execute in kernel mode therefore they also share data
that may affect the functionality of other processes. Hence, to avoid this condition,
reentrant function and locking mechanism is used.
Reentrant functions are one which allow processes to modify only the local variables and
do not affect global data variables.
I n locking mechanism several processes can execute reentrant function concurrently but
only one process at a time can execute non reentrant function, this will ensure that global
data is modified by only one process at a time and thus each process has same copy of
global data that is being shared among them.
Example: UNIX.
Multithreading
Thread: Light weight Process is called Thread.
Thread Vs Process
Thread Process
Light weight Process Heavy WeightProcess
ThreadSwitching does notneed interaction with OS ProcessSwitching needsinteractionwith OS
Thread can share Code segment, Data Section, File Processes own their separate Code segment, Data
Descriptor, address space, heap etc Section, File Descriptor, address space, heap etc
Register
Program1
Counter
Stack
Data Section
Code Segment
Heap
Address Space
File Descriptor
| Message Queue
Note: Local variables of the Process are stored in Stack, Global variables are stored in Data Section and dynamically
created variables are stored in Heap.
Multithreading Models
Many to One Model
I t maps many user level threads to one kernel level thread.
I n this model Entire Process is blockedif a thread makes blocking system
call.
Since only one thread can access the kernel at a time multiple threads are
wser hreasd
k o r vead
e r tread
k e n e d hrees
One-to-one mode.
-Lr wea