Os Unit Iii (Part-I)
Os Unit Iii (Part-I)
A computer system has many resources (hardware and software), which may be required to complete a task.
The commonly required resources are input/output devices, memory, file storage space, CPU, etc. The
operating system acts as a manager of the above resources and allocates them to specific programs and
users, whenever necessary to perform a particular task. Therefore the operating system is the resource
manager i.e. it can manage the resource of a computer system internally. The resources are processor,
memory, files, and I/O devices. In simple terms, an operating system is an interface between the
computer user and the machine.
An operating system acts similarly like government means an operating system performs no useful
function by itself; though it provides an environment within which other programs can do useful work.
Below we have an abstract view of the components of the computer system:
• The Computer Hardware contains a central processing unit(CPU), the memory, and the
input/output (I/O) devices and it provides the basic computing resources for the system.
• The Application programs like spreadsheets, Web browsers, word processors, etc. are used to
define the ways in which these resources are used to solve the computing problems of the users. And
the System program mainly consists of compilers, loaders, editors, OS, etc.
• The Operating System is mainly used to control the hardware and coordinate its use among the
various application programs for the different users.
• Basically, Computer System mainly consists of hardware, software, and data.
OS is mainly designed in order to serve two basic purposes:
1. The operating system mainly controls the allocation and use of the computing System’s resources
among the various user and tasks.
2. It mainly provides an interface between the computer hardware and the programmer that simplifies
and makes feasible for coding, creation of application programs and debugging
Two Views of Operating System
1. User's View
2. System View
Operating System: User View
The user view of the computer refers to the interface being used. Such systems are designed for one user to
monopolize its resources, to maximize the work that the user is performing. In these cases, the operating
system is designed mostly for ease of use, with some attention paid to performance, and none paid to
resource utilization.
Operating System: System View
The operating system can be viewed as a resource allocator also. A computer system consists of many
resources like - hardware and software - that must be managed efficiently. The operating system acts as the
manager of the resources, decides between conflicting requests, controls the execution of programs, etc.
Operating System Management Tasks
1. Process management which involves putting the tasks into order and pairing them into manageable
size before they go to the CPU.
2. Memory management which coordinates data to and from RAM (random-access memory) and
determines the necessity for virtual memory.
3. Device management provides an interface between connected devices.
4. Storage management which directs permanent data storage.
5. An application that allows standard communication between software and your computer.
6. The user interface allows you to communicate with your computer.
1. Types of Operating System
Given below are different types of Operating System:
1. Simple Batch System 5. Distributed Operating System
2. Multiprogramming Batch System 6. Clustered System
3. Multiprocessor System 7. Realtime Operating System
4. Desktop System 8. Handheld System
Functions of Operating System
1. It boots the computer
2. It performs basic computer tasks e.g. managing the various peripheral devices e.g. mouse, keyboard
3. It provides a user interface, e.g. command line, graphical user interface (GUI)
4. It handles system resources such as the computer's memory and sharing of the central processing
unit(CPU) time by various applications or peripheral devices.
5. It provides file management which refers to the way that the operating system manipulates, stores,
retrieves, and saves data.
6. Error Handling is done by the operating system. It takes preventive measures whenever required to
avoid errors.
Advantages of Operating System
Given below are some advantages of the Operating System:
• The operating system helps to improve the efficiency of the work and helps to save a lot of time by
reducing the complexity.
• The different components of a system are independent of each other, thus failure of one component
does not affect the functioning of another.
• The operating system mainly acts as an interface between the hardware and the software.
• Users can easily access the hardware without writing large programs.
• With the help of an Operating system, sharing data becomes easier with a large number of users.
• easily install any game or application on the Operating system easily and can run them
• operating system can be refreshed easily from time to time without having any problems.
• operating system can be updated easily.
Disadvantages of an Operating system
Given below are the drawbacks of using an operating system:
• Expensive
There are some open-source platforms like Linux. But some operating systems are expensive.
• Virus Threat
Operating Systems are open to virus attacks and sometimes it happens that many users download the
malicious software packages on their system which pauses the functioning of the Operating system
and also slows it down.
• Complexity
Some operating systems are complex in nature because the language used to establish them is not
clear and well defined. If there occurs an issue in the operating system then the user becomes unable
to resolve that issue.
• System Failure
An operating system is the heart of the computer system if due to any reason it will stop functioning
then the whole system will crashes.
Examples of Operating System
• Windows • Linux
• Android • Window Phone OS
• iOS • Chrome OS
• Mac OS
2.Evolution of Operating Systems
The evolution of operating systems is directly dependent on the development of computer systems and how
users use them. Here is a quick tour of computing systems through the past fifty years in the timeline.
Early Evolution
• 1945: ENIAC, Moore School of • 1951: UNIVAC by Remington
Engineering, University of Pennsylvania. • 1952: IBM 701
• 1949: EDSAC and EDVAC • 1956: The interrupt
• 1949: BINAC - a successor to the ENIAC
• 1954-1957: FORTRAN was developed
Operating Systems - Late 1950s
By the late 1950s Operating systems were well improved and started supporting following usages:
• It was able to perform Single stream batch processing.
• It could use Common, standardized, input/output routines for device access.
• Program transition capabilities to reduce the overhead of starting a new job was added.
• Error recovery to clean up after a job terminated abnormally was added.
• Job control languages that allowed users to specify the job definition and resource requirements were
made possible.
Operating Systems - In 1960s
• 1961: The dawn of minicomputers
• 1962: Compatible Time-Sharing System (CTSS) from MIT
• powerful, and really useful.
• 1967-1968: Mouse was invented.
• 1964 and onward: Multics
• 1969: The UNIX Time-Sharing System from Bell Telephone Laboratories.
Supported OS Features by 1970s
• Multi User and Multi tasking was introduced.
• Dynamic address translation hardware and Virtual machines came into picture.
• Modular architectures came into existence.
• Personal, interactive systems came into existence.
Accomplishments after 1970
• 1971: Intel announces the microprocessor
• 1972: IBM comes out with VM: the Virtual Machine Operating System
• 1973: UNIX 4th Edition is published
• 1973: Ethernet
• 1974 The Personal Computer Age begins
• 1974: Gates and Allen wrote BASIC for the Altair
• 1976: Apple II
• August 12, 1981: IBM introduces the IBM PC
• 1983 Microsoft begins work on MS- • 1992 The first Windows virus comes out
Windows • 1993 Windows NT
• 1984 Apple Macintosh comes out • 2007: iOS
• 1990 Microsoft Windows 3.0 comes out • 2008: Android OS
• 1991 GNU/Linux
An operating system is a construct that allows the user application programs to interact with the system
hardware. Operating system by itself does not provide any function but it provides an atmosphere in which
different applications and programs can do useful work.
The major operations of the operating system are process management, memory management, device
management and file management. These are given in detail as follows:
Process Management
The operating system is responsible for managing the
processes i.e assigning the processor to a process at a
time. This is known as process scheduling. The
different algorithms used for process scheduling are
FCFS (first come first served), SJF (shortest job
first), priority scheduling, round robin scheduling etc.
There are many scheduling queues that are used to
handle processes in process management. When the
processes enter the system, they are put into the job
queue. The processes that are ready to execute in the
main memory are kept in the ready queue. The
processes that are waiting for the I/O device are kept
in the device queue.
Memory Management
Memory management plays an important part in operating system. It deals with memory and the moving of
processes from disk to primary memory for execution and back again.
The activities performed by the operating system for memory management are −
• The operating system assigns memory to the processes as required. This can be done using best fit,
first fit and worst fit algorithms.
• All the memory is tracked by the operating system i.e. it nodes what memory parts are in use by the
processes and which are empty.
• The operating system deallocated memory from processes as required. This may happen when a
process has been terminated or if it no longer needs the memory.
Device Management
There are many I/O devices handled by the operating system such as mouse, keyboard, disk drive etc. There
are different device drivers that can be connected to the operating system to handle a specific device. The
device controller is an interface between the device and the device driver. The user applications can access
all the I/O devices using the device drivers, which are device specific codes.
File Management
Files are used to provide a uniform view of data storage by the operating system. All the files are mapped
onto physical devices that are usually non volatile so data is safe in the case of system failure.
The files can be accessed by the system in two ways i.e. sequential access and direct access −
• Sequential Access
The information in a file is processed in order using sequential access. The files records are accessed
on after another. Most of the file systems such as editors, compilers etc. use sequential access.
• Direct Access
In direct access or relative access, the files can be accessed in random for read and write operations.
The direct access model is based on the disk model of a file, since it allows random accesses.
4.Operating System Structure
operating system is a construct that allows the user application programs to interact with the system
hardware. Since the operating system is such a complex structure, it should be created with utmost care so it
can be used and modified easily. An easy way to do this is to create the operating system in parts. Each of
these parts should be well defined with clear inputs, outputs and functions.
Simple Structure
There are many operating systems that have a rather simple structure. These started as small systems and
rapidly expanded much further than their scope. A common example of this is MS-DOS. It was designed
simply for a niche amount for people. There was no indication that it would become so popular.
An image to illustrate the structure of MS-DOS is as follows −
It is better that operating systems have a modular structure, unlike MS-DOS. That would lead to greater
control over the computer system and its various applications. The modular structure would also allow the
programmers to hide information as required and implement internal routines as they see fit without
changing the outer specifications.
Layered Structure
One way to achieve modularity in the operating system is the layered approach. In this, the bottom layer is
the hardware and the topmost layer is the user interface.
An image demonstrating the layered approach is as
follows −
As seen from the image, each upper layer is built on the bottom layer. All the layers hide some structures,
operations etc from their upper layers.
One problem with the layered structure is that each layer needs to be carefully defined. This is necessary
because the upper layers can only use the functionalities of the layers below them.
5. Operating System - Services
An Operating System provides services to both the users and to the programs.
• It provides programs an environment to execute.
• It provides users the services to execute the programs in a convenient manner.
Following are a few common services provided by an operating system −
• Program execution
• I/O operations
• File System manipulation
• Communication
• Error Detection
• Resource Allocation
• Protection
Program execution
Operating systems handle many kinds of activities from user programs to system programs like printer
spooler, name servers, file server, etc. Each of these activities is encapsulated as a process.
A process includes the complete execution context (code to execute, data to manipulate, registers, OS
resources in use). Following are the major activities of an operating system with respect to program
management −
• Loads a program into memory.
• Executes the program.
• Handles program's execution.
• Provides a mechanism for process synchronization.
• Provides a mechanism for process communication.
• Provides a mechanism for deadlock handling.
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers hide the
peculiarities of specific hardware devices from the users.
An Operating System manages the communication between user and device drivers.
• I/O operation means read or write operation with any file or any specific I/O device.
• Operating system provides the access to the required I/O device when required.
File system manipulation
A file represents a collection of related information. Computers can store files on the disk (secondary
storage), for long-term storage purpose. Examples of storage media include magnetic tape, magnetic disk
and optical disk drives like CD, DVD. Each of these media has its own properties like speed, capacity, data
transfer rate and data access methods.
A file system is normally organized into directories for easy navigation and usage. These directories may
contain files and other directions. Following are the major activities of an operating system with respect to
file management −
• Program needs to read a file or write a file.
• The operating system gives the permission to the program for operation on file.
• Permission varies from read-only, read-write, denied and so on.
• Operating System provides an interface to the user to create/delete files.
• Operating System provides an interface to the user to create/delete directories.
• Operating System provides an interface to create the backup of file system.
Communication
In case of distributed systems which are a collection of processors that do not share memory, peripheral
devices, or a clock, the operating system manages communications between all the processes. Multiple
processes communicate with one another through communication lines in the network.
The OS handles routing and connection strategies, and the problems of contention and security. Following
are the major activities of an operating system with respect to communication −
• Two processes often require data to be transferred between them
• Both the processes can be on one computer or on different computers, but are connected through a
computer network.
• Communication may be implemented by two methods, either by Shared Memory or by Message
Passing.
Error handling
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the memory
hardware. Following are the major activities of an operating system with respect to error handling −
• The OS constantly checks for possible errors.
• The OS takes an appropriate action to ensure correct and consistent computing.
Resource Management
In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles and files
storage are to be allocated to each user or job. Following are the major activities of an operating system
with respect to resource management −
• The OS manages all kinds of resources using schedulers.
• CPU scheduling algorithms are used for better utilization of CPU.
Protection
Considering a computer system having multiple users and concurrent execution of multiple processes, the
various processes must be protected from each other's activities.
Protection refers to a mechanism or a way to control the access of programs, processes, or users to the
resources defined by a computer system. Following are the major activities of an operating system with
respect to protection −
• The OS ensures that all access to system resources is controlled.
• The OS ensures that external I/O devices are protected from invalid access attempts.
• The OS provides authentication features for each user by means of passwords.
User Operating-System Interface
There are two fundamental approaches for users to interface with the operating system. One technique is to
provide a command-line interface or command interpreter that allows users to directly enter commands that
are to be performed by the operating system. The second approach allows the user to interface with the
operating system via a graphical user interface or GUI.
Command Interpreter
Some operating systems include the command interpreter in the kernel. Others, such as Windows XP and
UNIX, treat the command interpreter as a special program that is running when a job is initiated or when a
user first logs on (on interactive systems). On systems with multiple command interpreters to choose from,
the interpreters are known as shells. For example, on UNIX and Linux systems, there are several different
shells a user may choose from including the Bourne shell, C shell, Bourne-Again shell, the Korn shell, etc.
Most shells provide similar functionality with only minor differences; most users choose a shell based upon
personal preference. The main function of the command interpreter is to get and execute the next user-
specified command. Many of the commands given at this level manipulate files: create, delete, list, print,
copy, execute, and so on. The MS-DOS and UNIX shells operate in this way. There are two general ways
in which these commands can be implemented. In one approach, the command interpreter itself contains
the code to execute the command.
Graphical User Interfaces
A second strategy for interfacing with the operating system is through a userfriendly graphical user
interface or GUI. Rather than having users directly enter commands via a command-line interface, a GUI
allows provides a mouse-based window-and-menu system as an interface. A GUI provides a desktop
metaphor where the mouse is moved to position its pointer on images, or icons, on the screen (the desktop)
that represent programs, files, directories, and system functions. Depending on the mouse pointer's location,
clicking a button on the mouse can invoke a program, select a file or directory—known as a folder— or
pull down a menu that contains commands. Graphical user interfaces first appeared due in part to research
taking place in the early 1970s at Xerox PARC research facility. The first GUI appeared on the Xerox Alto
computer in 1973.
.
However, with the release of Mac OS X (which is in part implemented using a UNIX kernel), the operating
system now provides both a new Aqua interface and command-line interface as well. The user interface can
vary from system to system and even from user to user within a system. It typically is substantially
removed from the actual system structure. The design of a useful and friendly user interface is therefore not
a direct function of the operating system. In this book, we concentrate on the fundamental problems of
providing adequate service to user programs. From the point of view of the operating system, we do not
distinguish between user programs and system programs.
System calls in Operating System?
The interface between a process and an operating system is provided by system calls. In general, system
calls are available as assembly language instructions. They are also included in the manuals used by the
assembly level programmers. System calls are usually made when a process in user mode requires access to
a resource. Then it requests the kernel to provide the resource via a system call.
A figure representing the execution of the system call is given as follows −
As can be seen from this diagram, the processes execute normally in the user mode until a system call
interrupts this. Then the system call is executed on a priority basis in the kernel mode. After the execution of
the system call, the control returns to the user mode and execution of user processes can be resumed.
In general, system calls are required in the following situations −
• If a file system requires the creation or deletion of files. Reading and writing from files also require a
system call.
• Creation and management of new processes.
• Network connections also require system calls. This includes sending and receiving packets.
• Access to a hardware devices such as a printer, scanner etc. requires a system call.