0% found this document useful (0 votes)
314 views22 pages

Operating System:: The Chapter Covers

The document provides an overview of operating systems. It discusses that an operating system acts as an interface between users and computer hardware, providing an environment for easy program execution and efficient hardware use. It describes the main components of a computer system and lists several key services operating systems provide, such as user interfaces, program creation/execution, I/O device access, file access control, protection/security, resource allocation, and error handling. The evolution of operating systems is also briefly covered, from early serial systems to modern parallel and distributed systems.

Uploaded by

pokop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
314 views22 pages

Operating System:: The Chapter Covers

The document provides an overview of operating systems. It discusses that an operating system acts as an interface between users and computer hardware, providing an environment for easy program execution and efficient hardware use. It describes the main components of a computer system and lists several key services operating systems provide, such as user interfaces, program creation/execution, I/O device access, file access control, protection/security, resource allocation, and error handling. The evolution of operating systems is also briefly covered, from early serial systems to modern parallel and distributed systems.

Uploaded by

pokop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Operating System :

Overview
Operating System :
1 Overview NOTES

The Chapter Covers :


n Introduction of Operating System
n Types of Operating System
n System Components and it's services
n System Calls
n System Programs, Structure, Design
and Implementation
n Operating System Generation

1.1 WHAT IS AN OPERATING SYSTEM ?


A computer machine is also known as computer system. A system can be defined
as- an integration of the individual components that work together to achieve some
objective. Similarly computer is also an integration of different components that
work together to acheive some objective. As with other system (for example car,
electric line) there is an interface (dashboard, switch board) that makes the opera-
tion of that system easy, similarly operating system, in the context of computer, is
an interface that makes the use of computer easy. We can define an Operating
system as a system program that runs all the time in background, usually called the
kernel, with all else being application programs. In the other words Operating
system is a program that acts as a mediator between a user of a computer and the 5
computer hardware. Its main aim is to provide an environment in which a user can
Operating Systems execute its program easily. An operating system was developed to achieve two main
goals. First goal is to make the computer system easy to use and the second goal
is to use the computer hardware efficiently.

NOTES A computer system consists of mainly four components.


1. The hardware : Such as CPU, memory and I/O devices provide the basic
computing resources.
2. Application programs : Such as compilers, database system and business
programs define the ways in which these resources are used to solve the com-
puting problems of the user.
3. Users : There may be many different users such as people, machine, and other
computers whose work is to solve different problems.
4. Operating System : Its work is to control and co-ordinate all the resources
and users.

End Users Programmer

Application
Operating
Program
System
Utilities designer
Operating System
Computer Hardware
Figure1.1, layers or hierarchy of a computer system

1.2 OPERATING SYSTEM SERVICES


As we have discussed above the primary goal of the Operating System is to provide
such an environment so that user can easily use the system and secondary goal is
to use the computer hardware efficiently. To make computer system easy to use
operating system provides so many services to the user. Briefly, the operating sys-
tem typically provides services in the following areas:
(i) User/Computer Interface:- The operating system hides the underlying details
of the working of the operating system and provides the user an easy interface
for using the system. It acts as mediator, making it easier for the programmer
and for application programs to access and use those facilities and services.
Different type of OS provides different types of interfaces. Interfaces can be
broadly categorized into
l Command-line Interface(CLI)- Uses text commands and a method for
6 entering them.
l Batch Interface- Commands and directives to control the commands are Operating System :
entered into files, and these files are executed. Overview

l Graphical User Interface(GUI)- All the services are available in the graphi-
cal format in the screen. Using some pointing device user can select the NOTES
service. User need not remember the commands.
(ii) Program Creation : OS provides variety of facilities and services, such as
editor and debuggers to help the user in the program creation and is making
it error free. Actually these services are utility program that are not the part of
OS but are accessible through the OS.
(iii) Program Execution : To execute a program a number of tasks are needed
to be performed. Instructions and data must be loaded into main memory, I/
O devices and files must be initialized, and other resources must be prepared.
The OS handles all these tasks for the user.
(iv) Access to I/O devices : Each I/O device require its own peculiar set of
instruction, or control signals, for operation. O/S take care of details so that
the programmer can use the I/O devices simply by issuing reads and write
command.
(v) Controlled Access to files : In the case of file control, it must include an
understanding of not only the nature of the I/O device (disk drive, tape drive)
but also the file format in the storage medium. The OS deals with the details.
Furthermore, in the case of a system with multiple simultaneous user the OS
can provide protection mechanism to control access to the files.
(vi) Protection and security : In the case of a shared or public system, the
operating system controls access to the system as a whole and to specific
system resources. Each component H/W or S/W that helps in the functioning
of the OS is called its resource, such as Memory, I/O device, Processor,
Application system programs, CPU time, File storage space etc. The Operat-
ing System has mechanisms for protection of resources and data from unau-
thorized access.
(vii) Communications : In the OS any work is done in the form of process.
Process is the unit of work. A program in execution is called a process. Many
times, during the execution, a process may require some information from other Check Your Progress
process. This information exchange is done by the communication between the 1. What is meant by
processes. The OS takes care of how this communication will take place Program creation?
between processes.
2. What is Protection
(viii)Error detection and response : A variety of errors can occur while a com- and Security?
puter system is running. These include internal and external hardware errors,
such as a memory errors, or a device failure and various S/W errors, such as
arithmetic overflow, attempt to access forbidden memory location etc. In each
case, the operating system must make the response that clears the error con-
dition with the least impact on running applications. The response may range
from ending the program that caused the error, to retrying the operation, to 7
simply reporting the error to the application.
Operating Systems (ix) Resource Allocation : A computer system has many resources (hardware
and software) that may be required to solve a problem. CPU times, memory
space, file storage space, I/O devices, and so on. The operating system acts
as the manager of these resources and allocate them to specific programs and
NOTES users as necessary for tasks. Since there may be many possibly conflicting
request for resources, the operating system must decide which requests are
allocated resources to operate the computer system efficiently and fairly.
(x) Accounting : A good operating system collects usage statistics for various
resources and monitors performance parameters such as response time. On
any system, this information is useful in anticipating the need for future enhance-
ments and in tuning the system to improve performance.
1.3 THE EVOLUTION OF OPERATING SYSTEM
(TYPES OF OPERATING SYSTEM)
1.3.1 Serial Operating System (It is not an OS)
In late 1940’s to the mid 1950’s, there was no OS. The programmer interacted
directly with the computer hardware. Each system had a console consisting of
display lights, toggle switches, some form of input device and a printer for output.
The Programmer wrote its program in machine code and loaded it with an input
device e.g. a card reader. If an error occurred, the program was halted. The error
condition was indicated by the lights. The programmer had to examine various
registers and main memory to determine the cause of the errors. If the program
reached to its normal completion, the output was printed through printer.
With these systems we had to face two types of problems:
1. Scheduling : To reserve machine time for a program a sign-up sheet was used.
Generally a user could sign a block of time in the multiple of 30 minutes. The
problem with this is that, if your program did not finish within 30 minutes due
to some problem you had to stop your program without resolving the problem.
Also, if you finished well before 30 minutes the computer will be idle till the
remaining time.
2. Setup time : The setup of a program was done in a sequence. A setting up of
a single program included loading the compiler plus the high level language
program (source program) into memory. Saving the compiled program (object
program). And then loading and linking together the object program and com-
mon functions. Each of these steps could involve mounting or dismounting tapes
or setting up the program to run.
If any error occurs during the setup process then whole work must be restarted
from the beginning.
1.3.2 Simple Batch Processing System
To reduce wastage of time caused by scheduling and setup time, the concept of a
batch operating system was developed.
The central theme behind this type of operating system is that- there is a small
software known as the monitor, the user did not interact directly with the computer
system. Rather, the user prepared a job (which consists of the code, the data and
some control information about the nature of the job (control cards)) and submitted
it to the computer operator. To speed up processing computer operator grouped
8
together the jobs (programs) with similar requirements and as the computer become
available would run each batch. For example suppose op- Operating System :
Operating
erator received request to run 3 programs say ‘A’, ‘B’ and Overview
another ‘A’. If he runs them in that order, he would have system
to set up for ‘A’ then for ‘B’ and finally ‘A’ again. If he
user program
runs the two ‘A’ programs as a batch, however he could NOTES
set up only once for ‘A’ thus saving operator’s time. area
The operating system (i.e. monitor) was a very simple
Figure 1.2 : simple
program. Its major task was to transfer control automati- batch operating system
cally from one job to the next.
Much of the OS must always reside in main memory and available for execution.
The rest of the OS consists of utility programs and common functions that are
loaded as subroutines to user programs at the beginning of any job that requires
them. The OS reads in jobs one at a time from the input device (such as card
reader). As it is read, the current job is placed in the user program area and control
is passed to this job. When the job is completed, it returns control to the OS which
immediately reads in the next job. After some time the output appeared, which
consists of the results of the program, as well as a dump of memory and registers
in case of program error.
Although, problem of scheduling of serial processing system was solved as a batch
of job is queued up and jobs are executed inturn without any dely. The setup
problem is handled with the use of job control language (JCL), which is a special
type of programming language used to provide instruction to the OS.
But with these type of system there was a problem that during execution CPU is
often idle because of a big difference in speed between I/O devices and CPU. To
solve this problem, rather than the cards being read directly from the card reader
into memory and then the job being processed, cards are read directly from the
card reader onto the disk. The location of card is recorded in a table by the
operating system. When that job is required for execution, it is read from the disk.
Similarly, when the job requests the printer to print a line, that particular line is
copied into a system memory called buffer and at the completion of the job data
is read from the disk and printed by the printer. This whole process is called
spooling. Spooling uses the disk as a intermediate place to hold the data to and from
I/O devices.

Figure1.2 : Spooling

By Spooling more than one input and output devices can interact with disk simul-
taneously and provide an impression that these devices interact directly with CPU,
so it is called Simultaneous Peripheral Operation On Line(SPOOL).
With a batch operating system there are two sacrifices : some main memory is now
given to the OS (monitor) and some CPU time is consumed by the monitor. Both
of these are forms of overhead. Even with these overhead the simple batch system 9
improves the use of the computer.
Operating Systems

Fig. :1.3 (a) Uniprogramming

NOTES

Fig. : 1.3(b) Multiple programming with two programs.

Figure 1.3 : (c) Multiple programming with three programs.

Advantages :
l Jobs are submitted in batch and wait in a queue therefore no problem of
scheduling.
l Instructions written in Job Control Language controls the loading and unloading
of programs hence there is no problem of setup time.
Disadvantages :
l Some main memory is now given over the OS.
l Some CPU time is consumed by OS.
l CPU is often idle because I/O devices are slower than CPU.
1.3.3 Multiprogrammed Batch System
Though the simple batch operating system solved the problem of scheduling by
automatic job sequencing but the processor time was still not fully utilized. The
problem is that mechanical I/O devices are slow compared to electronic processor.
Hence instructions for I/O are accomplished by the I/O devices with very slow
speed and during this period the CUP remains idle. See the figure 1.3(a). This
inefficiency can be removed if we can keep many programs in memory that are
10 ready to execute. We try to understand this with the help of simple example.
Suppose that in memory there is an OS and two user programs say A and B. Now Operating System :
when A needs to wait for I/O the processor can switch to B which likely is not Overview
waiting for I/O. See figure 1.3(b). Furthermore if there are three programs say A,
B, C OS can switch from A to B if A is waiting and B is not waiting, if both A and
B are waiting for I/O OS can switch to C (see figure 1.3(c)). We can expand the NOTES
number of programs till the main memory is fully occupied and allow OS to switch
among programs. Multiprogramming significantly improves the CPU utilization but
it requires certain decisions must be taken by the OS such as
l Scheduling : if many programs are ready to execute which program will be
executed by the CPU next (Scheduling),
l Memory Management : since there are more than one program where will these
programs be placed and how OS will manage the locality information (Memory
management),
l Intersupt handling and DMA : how the I/O devices will convey message that
they have finished the assigned task to OS so that the execution of that program
can be resumed ( interrupt handling and DMA)
Advantages :
l Multiprogramming utilizes system resources effectively.
l It has no problem of scheduling and setup time.
Disadvantages :
l User cannot interact with the job when it is executing. He had to predict the
result of the earlier job if next one is dependent upon the result of earlier one.
In most of the cases it is difficult to predict all the possible cases and define what
to do in these cases.
l Programs must be debugged statically from snapshot dump. A programmer
cannot modify a program during its execution to study its behaviour.
l Experimentation with program requires long turnaround time.
1.3.4 Multitasking (Time Sharing System)
Timesharing is the term concern with the allotment of computer resources on a basis
of timeslice to various program at same time. Time sharing or multitasking is a logical
expansion of multiprogramming. CPU switches one job from multiple jobs that are
ready to execute, but it switches so rapidly that the user may interact with each
program during its execution.
Unlike multiprogramming, where programs are executed till an I/O is reached or
program is terminated, in timesharing the CPU time is divided among all the pro-
grams. The main idea is that all programs have a small slice of the CPU time in turn.
Each program, beginning from the first program and proceeding towards the last is
allocated a very short period of CPU time (known as time slice, time slot or time
quantum) one by one. The processing speed of the system allows the CPU to
switch from one user to another and to do a part of each job in the allocated time
slice until the job is completed. However since the human reaction time is too slow
because interactive I/O typically runs at people speeds (Input may be bounded by
the user’s typing speed) the response time on a properly designed system gives the
illusion to each user that he alone is using the computer, whereas actually one
computer is being shared by many users.
11
Operating Systems An interactive computer system provides an on-line communication to the
OS or to a program directly and receives an immediate response. Usually a key-
board is used to give input and a display screen is used for output. When the
operating system finishes the execution of one command it seeks the next command
NOTES not from a card reader, but rather from the user’s keyboard. The user gives a
command, waits for the response and decides the next command based on the
result of the previous one. The user can easily experiment and can see result imme-
diately.
Some new features like virtual memory, file system are introduced first time in the
time sharing system.
Advantages :
l It allows to interact with the program during execution.
l Programs can be easily debugged.
l It reduces CPU idle time.
Disadvantages :
l A very frequent switching of CPU from one process to another required special
CPU scheduling algorithm.
l Since a CPU can switch during the execution of a process special memory
protection mechanism is required to protect one process data from accessing by
other process.
1.3.5 Multiprocessing System (Parallel System)
These type of OS have multiple processor which shares their bus, clock, memory
and input/output devices. These systems are called parallel computers, multicomputers,
or multiprocessors. They are also called tightly coupled system because they have
more than one processor in close communication sharing the computer bus, the
clock, memory and peripheral devices. The term multiprocessing is defined as
computers with two or more independent CPUs all having the capability to execute
several programs at same time. In such a system, instructions from different and
independent programs can be processed at the same instant of time by different
CPUs or the CPUs may simultaneously execute different instructions from the same
program.
Multiprocessing system can be further classified into
l Symmetric multiprocessing l Asymmetric multiprocessing
Symmetric multiprocessing
Symmetric multiprocessing is one in which each processor runs an identical copy of
the operating system and these copies communicate with one another as needed.
The benefit of the symmetric multiprocessing is that many process can run at once
without decreasing the performance. The weakness of the system is that, we must
carefully control I/O to ensure that data reach the appropriate processor. Also, since
the CPUs are separate, and there is no controlling device it can happen that one
processor is idle while another is overloaded.
Asymmetric multiprocessing
Asymmetric multiprocessing is one in which each processor is assigned a specific
task. Processors have a master-slave relationship. The master processor sched-
12
ules and allocates works to the slave processor. It is more common in very big
systems, where one of the big task is processing I/O. In such systems there are Operating System :
multiple processors at the user end whose work is just to process user’s input, Overview
controlling to these processors and other processing work is done by one or more
central processors.
Advantages of parallel systems NOTES

l Improved performance : Multiprocessing enhances the performance of com-


puter systems by permitting parallel processing of different portions of pro-
grams. This is proved that the performance is directly viewed by increased
throughput and lowered turnaround time of such systems.
l Save money : A multiprocessor system can also save money compared to
multiple single system because the processors can share resources such as
memory, power supply etc.
l Increase reliability : It gives us a facility of a built-in backup. If one of the
CPUs breaks down, the other CPU(s) automatically takes over the complete
workload until repairs are made. Thus, a complete breakdown of such system
is very rare i.e. reliability of system increases. If there are 10 processor in
system failure of 1 processor cause the entire system runs only 10 percent
slower.
Disadvantage :
l Existence of multiple processors requires a very sophisticated operating system.
1.3.6 Distributed system
A recent trend in computer system is to distribute computation among several
processors. This type of operating system is also called loosely coupled system
because processor do not share memory or clock. Each processor has its own
memory. These processors communicate with each other through various commu-
nication mediums (such as telephone lines, satellite etc.). Infact a distributed system
is a S/W system built on top of a network. The distinction between a network and
a distributed system lies with the S/W (OS), rather than with the H/W. The main
job of distributed OS is to hide the existence of multiple autonomous computer and
present that like a virtual uniprocessor. Allocation of jobs to processors and files to
disk movement of files between where they are stored and where they are needed
and all other system functions must be automatic.
Advantages :
The advantages of distributed systems are :
1. Resource sharing : If systems are connected, then a user at one site may
be able to use all the resources available on the connected site. In a small
organization where resources are limited ( such as there is only one printer and
one scanner between many users) resource sharing helps a lot in the overall
working of the organization. In general resource sharing includes sharing files at
remote sites, processing information in a distributed database, printing files at
remote sites using remote specialized hardware devices (such as high speed any
processor) and performing other operations.
2. Improved Computation speed : If a particular computation can be partitioned
into a number of sub computations then we can distribute sub computations
among the various connected systems that can run simultaneously. This will 13
result in the computation speedup. In addition, if a particular site is currently
Operating Systems overloaded with jobs some of them may be moved to other, lightly loaded,
sites.This movement of jobs is called load sharing.
3. Reliability : If one site fails in a distributed system, the remaining sites can
share the load. As in the parallel processing system failure of one processor
NOTES
does not halt the computation. Similarly failure of one site does not stop the
working of the distributed system.
4. Communication : Since the systems are connected in the distributed system
user can initiate file transfer or communicate with one another via electronic mail.
A user can send mail to another user at the same site or at a different site.
1.3.7 Real -Time System
A real time program is a program that must respond to the events within a certain
time period. And real time operating system is an operating system that can run real
time programs successfully. Real time system is a special purpose OS.This OS is
characterized by having time as a key factor. Application required that processing
should be performed within given time limit. Generally sensors bring data to the
computer that must be analyzed and adjust the control accordingly.
Often used as a control device in a dedicated application such as controlling scien-
tific experiments, medical imaging systems, industrial control systems, and some
display systems. Also include automobile engine fuel-injection systems, home-ap-
pliance controllers, and weapon systems. A real time operating system has pre-
defined fixed time constraints. Processing must be done within the defined con-
straints, othewise the system will be assumed as a failure. That means, a real time
system is considered to function correctly only if it returns the correct result within
specified time constraints. There are two types of real time system.
(a) Hard Realtime Operating System
Often there are hard deadlines that must be met which guarantees that critical task
completes on time. This OS guarantees that critical task be completed within a
certain range of time. For example, if a robot is hired to weld a car body, the car
will be damaged if a welding robot welds too early or too late. This OS requires
that all delays in the system be bounded
(b) Soft Realtime Operating System
There are many systems in which missing an occasional deadline is acceptable. For
example, it is impossible to give guarantee that certain read/write in a secondary
storage will be completed in predicted time because of the uncertain behaviour of
the secondary storage. In the Soft Realtime Operating System a critical real time
task gets priority over other tasks, and retains that priority until it completes.
There are several areas in which soft realtime systems are useful Multimedia, virtual
reality, and advanced scientific projects such as undersea exploration and planetary
rovers are some examples. These systems need advanced OS features that cannot
be supported by hard real time systems.
1.4 SYSTEM COMPONENTS
Modern Operating Systems can be divided into following components :
1.4.1 Process Management
A process is a program in execution. It is the unit of work in a system. Processes
14
can be of two types.
l Operating System Processes – These execute system code. Operating System :
l User Processes – These execute user code. Overview

This system component is responsible for the following tasks :


l User and system processes are created and deleted by the OS. NOTES
l Entire process communication is handled by the OS.
l Processes can be suspended for some I/O and then after completion of I/O,
these are resumed. These activities are handled by OS.
l Methods for handling deadlock are provided by OS.
l Process scheduling is also handled by OS.
1.4.2 Memory Management
For each program to be executed, it must be loaded into main memory. After
suspending for some activity, it is swapped into backing store then it is brought back
into memory for further execution. All these issues are handled by operating system.
This component is responsible for the following tasks :
1. Allocate and deallocate memory space to processes.
2. Decide which portion of memory are to be assigned to which process.
1.4.3 File Management
A file is a collection of data. Files are stored into directories. Files are stored into
the secondary storage devices. All these issues are handled by OS.
This component is responsible for the following tasks :
l The creation and deletion of files.
l The creation and deletion of directories.
l Commands for manipulating files and directories are provided by operation
system.
Check Your Progress
l Allocate space onto secondary storage.
3. What are the ad-
1.4.4 Secondary Storage Management vantages if Simple
Now-a-days disks are used as the main secondary storage medium. Hence disk batch Processing
storage management is the central task to a computer system. System?
This component is responsible for the following tasks : 4. What are advan-
l Free space management tages of multi pro-
l Disk scheduling gramming Batch
System
l Disk storage allocation
1.4.5 I/O System Management
I/O devices are the main component of computer system. Each I/O devices has its
own set of commands. Operating System hides these dissimilarities and provides an
easy interface to the user.
This component is responsible for the following tasks :
1. For providing easy interface to the user.
2. For buffering, caching and spooling.
15
Operating Systems 1.5 SYSTEM CALLS
Operating System consist of large number of functions. These functions are defined
to perform tasks needed by the OS. Such as CreateWindow(), ShowWindow(),
NOTES LoadIcon() etc. Some programming languages such as C, C++, VC++ has the
capability to invoke these functions directly to achieve the functionality. Even all the
instructions written in the programming languages are broken into these function calls
because work at the hardware level is actually accomplished through these func-
tions. That means these functions act as the interface between the OS and the
Application Program. Collection of these functions is called Application Program-
ming Interface (API). And call to these API functions is called System Call. The
system calls available in the interface, vary from operating system to operating
system.
To understand the system call let us see how a program is started and terminated.
When you click on some icon or type a command to execute a program, a system
call to run application is executed by the OS. If the OS is using GUI, running an
application involves create and display a window. Creating a window itself consists
of so many system calls such as LoadIcon( ) (to decide the icon), LoadCursor( )
(to decide the shape of the cursor), and to set background color etc. Once a
window is created and displayed on the screen user can perform some actions
(called event) on that particular window. Taking the event as input and processing
each event also involve system call such as GetMessage(), Update(),
TranslateMessage() etc. When a user tries to close that window again a system call
is executed which take care of the work to be performed in response to the user
action i.e. to terminate the application running on that window.
The API specifies a set of functions that are available to an application programmer,
including the parameters that are passed to each function and the return values the
programmer can expect. Three of the most common APIs available to application
programmers are the Win32 API for Windows system, the POSIX API for POSIX-
based system (includes all versions of UNIX, Linux and Mac OS X), and the Java
API for designing programs that run on the Java virtual machine.
Some of the major POSIX system calls are as follows-
1. System Calls for Process Management
a. fork( ):- Used to create a new child process. Returns a process id (pid) for
future reference.
b. Waitpid( ):- The syntax is
pid=waitpid(pid, &statloc, options)
Wait for a child to terminate. Returns a pid for future processing.
c. Execve( ):- The syntax is
s=Execve(name, argv, environp)
Replace a process’ core image. Return code s is -1 if an error has occurred.
d. exit():- The syntax is
exit(status)
Terminate process execution and return status.
16
2. System Calls for File management Operating System :
a. open():- The syntax is Overview

fd=open(file,how,…)
Open a file for reading, writing or both. Returns a file descriptor (fd). NOTES
b. close( ):- The syntax is
s=close(fd)
Close an opened file specified by the fd. Returns a code s that is -1 if an
error has occurred.
c. read( ):- The syntax is
n = read(fd, buffer, nbytes)
Read n bytes of data from a file specified by fd into a buffer. Returns actual
number of bytes read.
d. write( ):- The syntax is
n = write(fd, buffer, nbytes)
write n bytes of data into a file specified by fd from a specified buffer.
Returns actual number of bytes written.
e. lseek( ):- The syntax is
position=lseek(fd, offset, from)
Move the file pointer of the file specified by fd, to number of bytes specified
by offset from beginning, current position or end as specified by the from.
Returns the new position of the file pointer.
f. stat( ):- The syntax is
s=stat(name, &buf)
Get status information in the buf of a file specified by the name.
3. System Calls for Directory and file system management
a. mkdir( ):- The syntax is
s=mkdir(name, mode)
Create a new directory of the specified name and mode (read, write, execute).
b. rmdir( ):- The syntax is
s=rmdir(name)
Remove an empty directory in which name is specified as argument.
c. link( ):- The syntax is
s=link(name1, name2)
Create a new entry, name2, pointing to name1. After this call name2 can be
used as a link to name1.
d. unlink( ):- The syntax is
s=unlink(name)
Remove a directory entry for a link file.
e. mount( ):- The syntax is
17
s=mount(special, name, flag)
Operating Systems Allows two file systems to be merged into one. ‘special’ specifies device major or
minor number of the file system to be mounted, ‘name’ specifies the location where
the file system will be mounted and flag specifies whether the file system is to be
mounted read-write or read-only.
NOTES
f. unmount( ):- The syntax is
s=unmount(special)
Unmount a mounted file system.
4. Miscellaneous System Calls
a. chdir( ):- The syntax is
s=chdir(dirname)
Change the working directory.
b. chmod ( ):- The syntax is
s=chmod(name, mode)
Change the file’s protection bits. Mode can be read, write or execute.
c. kill( ):- The syntax is
s=kill(pid, signal)
Send a signal to a process specified by pid.
1.6 SYSTEM PROGRAMS
As you can see in hierarchy utility/system programs appears just above the Oper-
ating System. They provide a convenient environment for program development and
execution. They are-
1. Text Editor : This program is used for creating and editing text files. Using this
program any text matter can be typed and saved on a disk file. This file can be
retrieved any time and can also be edited, corrected etc. Text editor program
supports special commands for text editing i.e., you can insert, delete, find and
replace characters, lines and paragraphs.
2. File management : So many programs are available to perform file manage-
ment tasks such as create, delete, copy, rename, print, dump, list, and generally
manipulate files and directories.
3. Language Processors : As we know programmers prefer to write their pro-
grams in one of the High Level Languages (Language that are similar to English
like languages). However, the computer does not understand any language other
than its own machine language (binary language) therefore, it becomes neces-
sary to process a High level language program so as to make it understandable
18 to the computer. The system programs which perform this job are language
processors. These language processors can also be divided into – Operating System :
Overview
i. Assembler ii. Interpreter iii. Compiler
Debugger is also a system program that is used to rectify the logical errors
NOTES
(bugs) in a program.
4. Loader, Linker : When a program is created it may have many address
references to other locations. Each such reference can be expressed only sym-
bolically. The linker combines all such references in one place. Once a program
is assembled or compiled, it must be loaded into memory to be executed. The
system program which perform this task is called Loader.
5. Status information : To provide information about system performance, log-
ging details, disk space, system hardware, power management, system configu-
ration, date, time, memory availability, users detail and for similar status infor-
mation some system programs are available.
6. Communications : These system programs are used for creating virtual con-
nections among processes, users, and computer systems. These program allows
users to send messages to one another’s screens, to browse web pages, to send
electronic-mail messages, to log in remotely, or to transfer files from one ma-
chine to another.Together with these system programs this layer also contains
the utility programs. These utility programs includes data backup, anti virus, disk
defragmentor, data compression etc.
1.7 SYSTEM STRUCTURE
The first OS developed was very simple and small in size. With the evaluation of
OS more and more features have been added and the underlying hardware became
more complex and versatile. This results in the operating system of greater size and
complexity. The size of a full-featured operating system and the difficulty of the task
it addresses have led to three unfortunate but common problems.
1. Operating systems are chronically late in being delivered.
2. The systems have latent bugs that show up in the field and must be fixed and
reworked.
3. Performance is often not as what was expected.
To manage the complexity of operating systems and to overcome these problems,
much attention has been given to the software structure of the operating system. In
the following section, we will examine different structures that have been tried.
1. Simple Structure or Monolithic Systems
The OS is written as a collection of procedures, each of which can call any of the
other ones whenever it needs to. Each procedure in the system has a well-defined
interface in terms of parameters and results, and each one is free to call any other 19
one, if the latter provides some useful computation that the former needs. However,
Operating Systems it is possible to have at least a little structure. The services (system calls) provided
by the operating system are requested by putting the parameters in a well-defined
place (e.g., on the stack) and then executing a trap instruction. This instruction
switches the machine from user mode to kernel mode and transfers control to the
NOTES
operating system. The operating system then fetches the parameters and determines
which system call is to be carried out. After that, it indexes into a table that contains
in slot k a pointer to the procedure that carries out system call k.
This organization suggests a basic structure for the operating system:
1. A main program that invokes the requested service procedure.
2. A set of service procedures that carry out the system calls.
3. A set of utility procedures that help the service procedures.

Main
Program

Service
Procedure
s

Utility
Procedure
s
Figure 1.4, structure of a monolithic system

Level n

Level 3

Level 2

Level 1

20 Figure 1.5, Structure of Layered System


Operating System :
Overview
2. Layered Systems
In the operating systems of this structure, hundreds of thousands to the millions of
NOTES
lines of codes are arranged in the hierarchical layers. The hierarchical structure of
a modern operating system separates its functions according to their complexity,
their characteristic, time scale and their level of abstraction. Whole operating system
can be viewed as a series of levels. Each level performs a related subset of the
functions required of the OS. It relies on the next lower level to perform more
primitive functions and to conceal the details of those functions. It provides services
to the next higher layer. Levels are defined in such a way so that changes in one
level do not require changes in other levels. This can be understood with the help
of following figure 1.5.
Advantage of this structure is simplicity of construction and debugging. Each layer
can be implemented without the knowledge of the other layers. Each layer can be
debugged without any concern for the rest of the system. That means each layer
hides its own functionality and provides an easy interface to its higher layers from
where higher layer can demand for services. But the disadvantage with this ap-
proach is that it is very difficult for designers to appropriately define the number of
layers and identify the functionality of each layer. The other disadvantage is in the
approach of the system call. If an application wants the service of the lower layer,
it will make a system call for top level with passing some values as parameter,
system call to this layer will again make a system call to its lower layer and so on
till the system call for the desired layer is not reached. At each layer, the parameters
may be modified; data may need to be passed, and so on. That means each layer
adds sufficient overhead to the system call; and this results in a system call that takes
longer time than the system call of nonlayered system. An example OS that has a
layered structure is UNIX Operating system. Figure 1.6 shows structure of UNIX
Operatings system.
3. Microkernels
Check Your Progress
A trend in modern operating systems is to remove all nonessential components from
5. What is meant by
the kernel layer and move them up into the higher layers where user level programs
status information
are kept. This approach reduces the size of the kernel drastically. This kernel is
under system pro-
called microkernel. Although, there is a little difficulty to do so, because a designer
grams?
have to decide which services should be implemented as a part of kernel and which
services should be implemented in user space. Generally a microkernel is designed
to take care about process management, memory management and communication
between the processes. All the processes are divided into client and server pro-
cesses. Client process request for services and the server process provides the
service. The kernel handles the communication between the clients and servers.

21
Operating Systems

NOTES

Figure 1.6, layered structure of UNIX Operating system

The advantage of this microkernel approach is that


1. Splitting the operating system up into parts, as shown in the figure1.7, each part
becomes small and manageable.
2. All the servers run as user-mode process, and not in kernel mode, hence they
do not have direct access to the hardware. So, if there is a bug in any server
only that server will crash not the whole system.
3. Modification and addition to the user space do not require modification of the
kernel and also if any modification in the kernel is required it is comparatively
easy as microkernel is a smaller kernel.
Although microkernel has all these advantages but it can suffer from poor perfor-
mance due to increased system function overhead.
4. Modules
As the advantages of object oriented programming are acknowledged, OS design-
ers also started thinking about the implementation of OS as collection of object
modules. There is one core kernel and number of dynamically loadable kernel
modules such as scheduling classes, file systems, loadable system calls etc. This
approach combines the layered system and microkernel in that each kernel section
has defined, protected interfaces (hiding concept of object oriented programming
that allows a restricted access to its members) which is more flexible than a layered
system and the primary kernel module has only core functions and knowledge of
how to load and communicate with other modules (like microkernel systems) but
it is more efficient, because modules do not need to invoke message passing in
order to communicate as in microkernel. Figure 1.8 shows the structure.

22
Operating System :
Overview

NOTES

figure 1.7, structure of microkernel

1.8 SYSTEM DESIGN AND IMPLEMENTATION


As Software Engineering suggest, to develop a good operating system it is required
to prepare a system design which helps to identify the functional requirements of the
operating system. Designing and implementing an OS is a highly creative task which
involves the understanding of the general principle of software engineering. There-
fore we discuss only some of the key design issues that occur in operating system
and the way they are implemented in the following two sections.
Design issues
As we have stated earlier, system designing is a very creative task, but in this phase
we find the answers of the following questions-
ê What is the minimum hardware required?
ê Which type of the system we are going to design? Whether it will be a single
user or multiuser, batch or multitasking, distributed or real time etc.
ê What are the goals of operating system? Answer must include user goals (such
as easy to use, reliable, powerful, safe and fast) as well as the system goals
(such as easy to design, implement, and maintain, flexible, reliable, error free
and efficient).
ê What will be the system structure? Monolithic, layered, microkernel or moduler.
ê How will be the interface? CUI or GUI.
ê What services/functionality will be included in the operating systems?
ê What data structures will be used to attain the functionality?
Implementation
Designing decides what to do but it does not specify how to do. As with other
application development, to develop operating system it is required to implement the
design that has been prepared. To implement the design first task is to decide the
programming language. In early days operating system is written in assembly lan-
guage. But current operating systems are developed using C or C++. The selection
of the type of language is important as writing in assembly language is difficult but
fast while writing in high level language is comparatively easy but slow. If the 23
operating system is developed in high level language it has inherent features of high
Operating Systems
Module 4
.
Module 3
NOTES
.
Core
Kernel

Module 2 Module n

Module 1

figure 1.8, moduler structure


level languages such as easy to understand and debug, portable etc. The second
important task in the implementation is to select the efficient algorithms. Because
operating system is responsible for the overall system performance each algorithm
must be selected carefully. Once a system is written it must be checked for all
possible error conditions and if any erroneous routine found it is to be corrected.
1.9 OPERATING SYSTEM GENERATION
Once an operating system is written and tested it is ready for distribution. Generally
operating system is distributed on disk or CD-ROM. An operating system is imple-
mented and tested in a particular site but we want to distribute it to work on any
site. This requires some sort of configuration according to each specific computer
site; this process is sometimes called system generation (SYSGEN). The SYSGEN
program configures the hardware system. The necessary information for the configu-
ration is either asked by the user of the computer or SYSGEN automatically probe
the hardware and related information. To generate an operating system following
types of information is required-
 Which type of CPU is being used? What are the settings of the CPU? For
multiple CPU system description of each CPU is required.
 What is the capacity of memory? SYSGEN determines itself the available memory.
 What devices are available? And how to refer them i.e. its device number, its
type and model, device interrupt number and any special device characteristics
required.
 What options of operating system are required? For example how many buffers
should be used and what should be the size of each buffer, what should be the
size of swap space for memory management etc.
After getting all these information operating system is completely compiled. Data
declarations, initializations, and constants, creation of necessary tables, along with
conditional compilation, produce an output object version of the OS. Now-a-days
24
device drivers for all supported devices are kept in a separate library but only those
needed are linked into the operating system. Operating System :
Overview
ANSWER TO CHECK YOUR PROGRESS
1) Program Creation : OS provides variety of facilities and services, such as
NOTES
editor and debuggers to help the user in the program creation and is making it error
free. Actually these services are utility program that are not the part of OS but are
accessible through the OS.
2) Protection and security : In the case of a shared or public system, the op-
erating system controls access to the system as a whole and to specific system
resources. Each component H/W or S/W that helps in the functioning of the OS
is called its resource, such as Memory, I/O device, Processor, Application
system programs, CPU time, File storage space etc. The Operating System has
mechanisms for protection of resources and data from unauthorized access.
3) Advantages :
l Jobs are submitted in batch and wait in a queue therefore no problem of
scheduling.
l Instructions written in Job Control Language controls the loading and un-
loading of programs hence there is no problem of setup time.
4) Advantages :
l Multiprogramming utilizes system resources effectively.
l It has no problem of scheduling and setup time.
5) Status information : To provide information about system performance, log-
ging details, disk space, system hardware, power management, system configu-
ration, date, time, memory availability, users detail and for similar status infor-
mation some system programs are available.
TEST YOURSELF
1. What is the need for an operating system?
2. Define OS? Explain the importance of System Call in OS.
2. What is meant by a “system Call”? How does an Application Program use
these calls during execution?
3. What are the functions of an operating system?
4. Describe multiprogramming operating system.
5. What are the new features added in the time sharing system that are not in
multiprogramming system ?
6. Explain multiprocessing system. What are the advantages of it?
25
7. What is OS? Describe the following operating systems :
Operating Systems a. Batch processing system b. Time sharing system
c. Real time system d. Personal computer system
8. Differentiate between Multiprogramming, Multitasking and Multiprocessing system.
NOTES
9. Discuss various categories of system call.
10. Give the steps of system generation.
11. What is the aim of System Program?
12. Explain System Structure.
13. What are Distributed system?
14. What do you understand by system component? Explain the main components
of Operating system.
15. What is the difference between buffering and spooling ?
16. Explain system call and give the type of system call.
17. Explain Hierarchical structure of operating system.
18. Explain OS functions.
19. Explain the role of system call in Unix OS.

20. Explain distributed and parallel system.

26

You might also like