Sie sind auf Seite 1von 6


Introduction to Operating system

- OS is a collection of programs. It is a software that supports computer's basi
c functions.
- OS acts as an interface between applications and computer hardware.
- OS also manages the computer hardware by creating a uniform set of functions t
hat can be performed on various classes of devices. These functions rely on a la
yer of drivers that provide specific means to carry out operations on specific h
- OS is the core software component of a computer. It performs many functions an
d acts as interface between computer and outside world.
- OS provides interface to hardware by use of drivers.
- OS basically manages all internal components of a computer. It was developed t
o better use the computer.
4.1 Basic Resources managed by OS
Following are the basic resources managed by OS:
- Memory Space (Memory Management)
- CPU time (Process Management)
- Disk Space (File System Management)
- Input-output device (Device Management)
4.1a Basics of Memory Management
- any program needs to be loaded in RAM before it can be executed. RAM is comput
er memory that can be accessed randomly.
- Memory Management deals with managing computer's primary memory. It decides th
e amount of memory to be allocated to a particular program.
- it also keeps track of the free as well as allocated memory. Memory management
applies ONLY to RAM.
- aim is to utilize the available memory effectively. Fragmentation should be mi

i) Fragmentation
- occurs when there are many free small blocks in memory that are too small to s
atisfy any request.
- it is a phenomenon in which storage space is used inefficiently resulting in r
educed capacity and performance. Also leads to wastage of storage space.
Types of Fragmentation- External, Internal, Data
- can be present in isolation or conjunction.
- when a program starts, there are long and contiguous free memory areas. Over t
ime and with use these become fragmented into smaller areas and eventually it be
comes impossible for program to request large paritions of memory.
Internal Fragmentation
- it is the space wasted inside the allocated memory block because of the restri
ction on allowed sizes of allocated blocks. Allocated memory can be slightly lar
ger than requested memory.
- the size difference is the memory internal to partition but would not be used.
Design change is the best way to remove internal fragmentation. Example, by usi
ng dynamic allocation.
External Fragmentation
- happens when dynamic memory allocation algorithm allocates some memory and a s
mall piece is left over which cannot be used effectively.
- the amount of usable memory reduces drastically if too much external fragmenta

tion occurs. Total memory available is enough to satisfy a request but it is not
contiguous so it is wasted.
Data Fragmentation
- occurs when a collection of data in memory is broken up into many pieces that
are not close enough. It is typically the result of attempting to insert a large
object into storage that has already suffered external fragmentation.
ii) Memory Management Techniques
> Single Contiguous Allocation
> Partitioned Memory Management Scheme
> Paged Memory Management
> Segmented Memory Management
Single Contiguous Allocation
- simplest type of memory management in which all memory except a small portion
is available for a program to run. So only one program is loaded and remaining m
emory is wasted. Ex: MS-DOS
- advantage is that it supports fast sequential and direct access and provides g
ood performance as number of disk seeks are minimum.
- disadvantage is that it causes fragmentation.
Partitioned Memory Management Scheme
- divides primary memory into multiple memory partitions, usually contiguous mem
ory areas. Memory management is that a particular partition is allocated to a pr
ogram when it starts and is deallocated when it ends.
- A is the base register address which is the lowest address a process may refer
to. Length of a partition can be found from the Bounds register. Bounds registe
r stores the lower and upper bound of addresses in time sharing environment.
- time sharing environment refers to the use of computer by multiple users at th
e same time.
>Fixed Memory Partitioning (Static Partitioning)
- main memory is divided into a number of static partitions and a process may be
loaded into a partition of equal or greater size.
- advantage is simplicity in implementation and little overhead. Disadvantage is
internal fragmentation, also maximum number of processes are fixed.
>Variable Memory Partitioning (Dynamic Partitioning)
- partitions are created dynamically so that all processes are loaded in paritio
ns having equal size as that of process.
- advantage is no internal fragmentation and efficient use of memory, disadvanta
ge is external fragmentation.
Paged Memory Management
- divides primary memory into fixed size units known as page frames. Program's a
ddress space is divided into pages of same size.
- in this, each process runs in it's own memory space. Advantage is that there i
s no external fragmentation but a little of internal fragmentation.
- CPU generates a page number which is indexed in a page table. The correspondin
g entry in page table gives the frame number which is then added to the displace
ment(offset, same as that for page number) to get the final physical address.
Segmented Memory Management
- computer's main memory is divided into segments. In this, there is a referece
to memory location that includes a value. This value identifies a segment and an
offset within that segment.
- this scheme does not provide single contiguous memory allocation.
- segmentation allows better access protection than other schemes because refere
nces are relative to a segment and offset that is not in that segment will not b

e allowed.
- Segmentation with paging eliminates external fragmentation and has the ability
to handle growing data.
4.1b Process Management
- CPU has multiple processes running at a time and many are waiting in queue to
be executed. CPU should schedule all these processes.
Process creation involves four principle events:
> System initialization or start up.
> A process is run to execute a process creation system call.
> Request to create a new process is issued by user.
> Batch job initiation, when a batch is finished and CPU has enough resources fo
r next process, it in initialized.
- foreground processes are those that interact directly with the user, like taki
ng input or showing output.
- backgroud processes are those, that do not interact directly with user, like s
howing clock etc.
- common reasons for program termination are: user log off, normal termination,
error and fault, time limit exceed, memory unavailable, I/O failure.
Pre-emptive Scheduling
- a running task is interrupted in between its execution because a higher priori
ty task is required to be completed.
- the interrupted task is either blocked or put in suspended state and resumed l
Non pre-emptive Scheduling
- a running task executes till it completes fully. It cannot be interrupted befo
re it completes its servicing.
- ready state of a process means that it is ready to be executed. It is loaded i
n memory and is waiting for the processor.
- running state is a state in which a process is currently running. It can be mo
ved to suspended state and resumed later.
- a process may be blocked due to reasons such as when a particular process has
exhausted, the CPU time allocated to it, it is waiting for an event to occur. Th
ey can move to either ready or suspended state.
- suspended state: a process moved from main memory to virtual memory. Can be la
ter moved to ready state.
- process keeps on changing states unless it reaches termination.
4.1c File System Management
- helps to manage and organize the files in such a way that their retrieval is f
aster and easier.
- file system manager is used by the OS to do file system management. It keeps t
rack of all files and directories on secondary storage media.
- OS does the following for a efficient file management:
> able to identify numerous files by giving unique names to them.
> maintains a list to keep track of exact file location.
> provides fast and simple algorithms to write and read files in cooperation wit
h device manager.
> grant and deny access rights to programs and users.
> allocate and de-allocate files so that they can be processed.
> provide programs and users with simple commands for handling files.
- on storage media, files are saved in blocks or sectors. To access these, file
manager and device manager works together.
- device manager knows where to find each sector on disk, but only file manager
has a list telling in what sectors either file is stored.

- this list is called File Allocation Table(FAT). It has been in use under DOS f
or a long time.
Contiguous File Allocation
- at the time of file creation, a single set of blocks is allocated to a file an
d each file is stored contiguously in sectors, one sector after another.
- advantage is that FAT has a single entry for each file consisting of start add
ress, length and name, and it is easy to get a single block because its address
can be easily calculated.
- disadvantage may be that it can be difficult to get a sufficiently large block
of contiguous memory block.
- now it is used only in tapes and recordable CDs.
Non-contiguous File Allocation
- all blocks of a file can be distributed all over the storage. The FAT also has
an entry for each sector the file occupies.
- advantage is that it is easy to get a single block, because each block has its
entry in FAT, and it is a simple allocation method where no overhead is produce
d and no search method for free blocks in needed.
- disadvantage is that compaction is required from time to time as FAT becomes e
normous which can slow down the system.
- used in MS-DOS
Chained Allocation
- only the first block of the file gets an entry in the FAT, each sector has dat
a as well as pointer to the next sector to be accessed after it.
- advantage is that FAT has a single entry for each file and there is no need to
store the files contiguously.
- disadvantage is that it takes much time to receive a single block because that
information is neither stored anywhere not can it be calculated. If a particula
r sector is to be accessed, then all its previous sectors are required to be acc
- used in Unix i-node which is an OS that used i-nodes as its data structures.
Indexed Allocation
- only the first block gets entry in FAT and no data is stored in this sector. I
t only has pointers to where the file is on a storage medium. That is why, first
block is called the index block.
- advantage is that retrieving a single block is easy because information about
it is stored in first block.
- disadvantage is that for each file an additional sector is needed to keep trac
k of the location of a file.
- a very small always occupies two blocks, where as data cold have easily fitted
in one. This results is space wastage.
- implemented in UNIX systems. It is reliable as well as fast.
4.1d Device Management
- OS also deals with device management, specially I/O devices. In a multi user s
ystem, there are shared devices and management of these by sending appropriate c
ommands is major task of OS.
- a software routine that knows how to deal with each device is called a driver
and OS requires drivers for the peripherals attached to computer. When a new per
ipheral is added, device driver is installed into the operating system.
- OS also deals with the access time of these devices, it helps make the device
access fast and in the most efficient way possible.
- major concern is to prevent deadlock situation.
Dead Lock
- it is a situation where each set of processes is waiting for an event that onl

y other process in the set can cause.

- Process 1 requires printer that is being used in Process 2 and Process 2 requi
res monitor which is used by Process 1.
- this causes an indefinite wait for processes leading to a situation known as d
- mutex: mutual exclusion object which is a logical unit. It is a program object
that allows multiple program threads to share the same resource but not simulta
neously. File access is an example of mutex.
- strategies for dealing with deadlock:
> ostrich algorithm: ignoring the problem altogether. It assures that ignoring t
he problem would be more cost-effective as compared to allowing the problem to o
ccur and then attempt its prevention.
> Detection and Recovery.
> Avoiding deadlock by careful resource allocation.
> Prevention of deadlock by structurally negating one of the 4 necessary conditi
Necessary conditions of deadlock
- mutual exclusion: resouces involved are non sharable.
- Hold and wait: requesting process hold resources while waiting for requested r
- No pre-emptive condition: resources already allocated to a process cannot be p
- Circular wait: process in the system forms a circular list or chain where each
process in the list is waiting for a resource held by next process in list.

4.2 Resource Sharing Management

- primary task of OS is to keep track of resources like memory, CPU utilization,
storage device, and I/O devices, to grant resource reqests, to mediate conflict
ing requests from different programs etc.
4.2.1 Multiplexing
- method by which multiple analog data signals/ digital data streams are combine
d into one signal over a shared medium. It is used to share an expensive resourv
e and this help reduce cost.
- Communication channel is used for transmission of a multiplexed signal, this c
hannel may be a physical transmission medium. Multiplexing basically works on th
e principle of division of signals.
- capacity of the channel is divided into several low level logical channels. Ea
ch channel maps to each message signal or data stream to be transferred.
- reverse of this process is called demultiplexing. It can extract the original
channels or signals on the receiver side.
- device that performs the task of multiplexing is called a multiplexer and a de
vice that performs demultiplexing is called demultiplexer.
Time Multiplexing
- when different programs/users get their turn to use that resource one after an
- turns for usage are decided as per the predefined operating system algorithm.
- it is used in printer.
Space Multiplexing
- the resource is shared equally in the available space. Time period for which t
he resource is used does not matter anymore.
- each gets a part of the resource. Hard disk, main memory etc are examples of s
pace multiplexing.

Scheme- scheme in documents refers to techniques.
Process- job or a program that executes in memory.
Data Array- ordered list of items
Data Structure- particular way of storing and organizing data in a computer so t
hat it can be used efficiently.