Unit- 1: Introduction of operating system
An Operating System (OS) is an interface between a computer user and computer
hardware. An operating system is a software which performs all the basic tasks like
file management, memory management, process management, handling input and
output, and controlling peripheral devices such as disk drives and printers.
Definition
An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.
Some popular Operating Systems include Linux Operating System, Windows
Operating System, VMS, OS/400, AIX, z/OS, etc.
Following are some of important functions of an operating System.
Memory Management
Processor Management
Device Management
File Management
Security
Control over system performance
Job accounting
Error detecting aids
Coordination between other software and users
1. Memory Management- Memory management refers to management of
Primary Memory or Main Memory. Main memory provides a fast storage that
can be accessed directly by the CPU. For a program to be executed, it must in
the main memory.
An Operating System does the following activities for memory
management:
Keeps tracks of primary memory, i.e., what part of it are in use by whom,
what part are not in use.
In multiprogramming, the OS decides which process will get memory when
and how much.
Allocates the memory when a process requests it to do so.
De-allocates the memory when a process no longer needs it or has been
terminated.
2. Processor Management- In multiprogramming environment, the OS decides
which process gets the processor when and for how much time. This function
is called process scheduling.
An Operating System does the following activities for processor management:
Keeps tracks of processor and status of process. The program responsible
for this task is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when a process is no longer required.
3. Device Management - An Operating System manages device
communication via their respective drivers.
It does the following activities for device management:
Keeps tracks of all devices. The program responsible for this task is known
as the I/O controller.
Decides which process gets the device when and for how much time.
Allocates the device in the most efficient way.
De-allocates devices.
4. File Management- A file system is normally organized into directories for
easy navigation and usage. These directories may contain files and other
directions.
An Operating System does the following activities for file management:
Keeps track of information, location, uses, status etc. The collective
facilities are often known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
In addition to this, following are some of the important activities that an
Operating System performs
Security − By means of password and similar other techniques, it prevents
unauthorized access to programs and data.
Control over system performance − Recording delays between request for a
service and response from the system.
Jobaccounting − Keeping track of time and resources used by various jobs
and users.
Error detecting aids − Production of dumps, traces, error messages, and other
debugging and error detecting aids.
Coordination between other softwares and users − Coordination and
assignment of compilers, interpreters, assemblers and other software to the
various users of the computer systems.
Types of operating system
Operating systems are there from the very first computer generation and they keep
evolving with time.
1. Batch operating system
The users of a batch operating system do not interact with the computer directly.
Each user prepares his job on an off-line device like punch cards and submits it to
the computer operator. To speed up processing, jobs with similar needs are batched
together and run as a group. The programmers leave their programs with the
operator and the operator then sorts the programs with similar requirements into
batches.
The problems with Batch Systems are as follows −
Lack of interaction between the user and the job.
CPU is often idle, because the speed of the mechanical I/O devices is slower
than the CPU.
Difficult to provide the desired priority. Batch processing is a technique in which
an Operating System collects the programs and data together in a batch before
processing starts. An operating system does the following activities related to
batch processing −
The OS defines a job which has predefined sequence of commands, programs
and data as a single unit.
The OS keeps a number a jobs in memory and executes them without any
manual information.
Jobs are processed in the order of submission, i.e., first come first served
fashion.
When a job completes its execution, its memory is released and the output for
the job gets copied into an output spool for later printing or processing.
Advantages
Batch processing takes much of the work of the operator to the computer.
Increased performance as a new job get started as soon as the previous job
is finished, without any manual intervention.
Disadvantages
Difficult to debug program.
A job could enter an infinite loop.
Due to lack of protection scheme, one batch job can affect pending jobs.
2. Time-sharing operating systems
Time-sharing is a technique which enables many people, located at various
terminals, to use a particular computer system at the same time. Time-sharing or
multitasking is a logical extension of multiprogramming. Processor’s time
which is shared among multiple users simultaneously is termed as time-sharing.
The main difference between Multi-programmed Batch Systems and Time-
Sharing Systems is that in case of Multi-programmed batch systems, the objective
is to maximize processor use, whereas in Time-Sharing Systems, the objective is to
minimize response time.
Multiple jobs are executed by the CPU by switching between them, but the
switches occur so frequently. Thus, the user can receive an immediate response.
For example, in a transaction processing, the processor executes each user program
in a short burst or quantum of computation. That is, if n users are present, then
each user can get a time quantum. When the user submits the command, the
response time is in few seconds at most.
The operating system uses CPU scheduling and multiprogramming to provide
each user with a small portion of a time. Computer systems that were designed
primarily as batch systems have been modified to time-sharing systems.
Advantages of Timesharing operating systems are as follows −
Provides the advantage of quick response.
Avoids duplication of software.
Reduces CPU idle time.
Disadvantages of Time-sharing operating systems are as follows −
Problem of reliability.
Question of security and integrity of user programs and data.
Problem of data communication.
3. Distributed operating System
Distributed systems use multiple central processors to serve multiple real-time
applications and multiple users. Data processing jobs are distributed among the
processors accordingly.
The processors communicate with one another through various communication
lines (such as high-speed buses or telephone lines). These are referred as loosely
coupled systems or distributed systems. Processors in a distributed system may
vary in size and function. These processors are referred as sites, nodes, computers,
and so on.
The advantages of distributed systems are as follows −
With resource sharing facility, a user at one site may be able to use the
resources available at another.
Speedup the exchange of data with one another via electronic mail.
If one site fails in a distributed system, the remaining sites can potentially
continue operating.
Better service to the customers.
Reduction of the load on the host computer.
Reduction of delays in data processing.
4. Network Operating System
A Network Operating System runs on a server and provides the server the
capability to manage data, users, groups, security, applications, and other
networking functions. The primary purpose of the network operating system is
to allow shared file and printer access among multiple computers in a network,
typically a local area network (LAN), a private network or to other networks.
Examples of network operating systems include Microsoft Windows Server
2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell
NetWare, and BSD.
The advantages of network operating systems are as follows:
Centralized servers are highly stable.
Security is server managed.
Upgrades to new technologies and hardware can be easily integrated into the
system.
Remote access to servers is possible from different locations and types of
systems.
The disadvantages of network operating systems are as follows:
High cost of buying and running a server.
Dependency on a central location for most operations.
Regular maintenance and updates are required.
5. Real Time operating System
A real-time system is defined as a data processing system in which the time
interval required to process and respond to inputs is so small that it controls the
environment. The time taken by the system to respond to an input and display of
required updated information is termed as the response time. So in this method,
the response time is very less as compared to online processing.
Real-time systems are used when there are rigid time requirements on the
operation of a processor or the flow of data and real-time systems can be used as a
control device in a dedicated application. A real-time operating system must have
well-defined, fixed time constraints, otherwise the system will fail. For example,
Scientific experiments, medical imaging systems, industrial control systems,
weapon systems, robots, air traffic control systems, etc.
There are two types of real-time operating systems.
Hard real-time systems
Hard real-time systems guarantee that critical tasks complete on time. In hard real-
time systems, secondary storage is limited or missing and the data is stored in
ROM. In these systems, virtual memory is almost never found.
Soft real-time systems
Soft real-time systems are less restrictive. A critical real-time task gets priority
over other tasks and retains the priority until it completes. Soft real-time systems
have limited utility than hard real-time systems. For example, multimedia, virtual
reality, Advanced Scientific Projects like undersea exploration and planetary
rovers
6. Multitasking
Multitasking is when multiple jobs are executed by the CPU simultaneously by
switching between them. Switches occur so frequently that the users may interact
with each program while it is running. An OS does the following activities related
to multitasking −
The user gives instructions to the operating system or to a program directly,
and receives an immediate response.
The OS handles multitasking in the way that it can handle multiple
operations/executes multiple programs at a time.
Multitasking Operating Systems are also known as Time-sharing systems.
TheseOperating Systems were developed to provide interactive use of a
computer system at a reasonable cost.
A time-shared operating system uses the concept of CPU scheduling and
multiprogramming to provide each user with a small portion of a time-shared
CPU.
Each user has at least one separate program in memory.
A program that is loaded into memory and is executing is commonly referred to
as a process.
When a process executes, it typically executes for only a very short time before
it either finishes or needs to perform I/O.
Since
interactive I/O typically runs at slower speeds, it may take a long time to
complete. During this time, a CPU can be utilized by another process.
The operating system allows the users to share the computer simultaneously.
Since each action or command in a time-shared system tends to be short, only a
little CPU time is needed for each user.
Asthe system switches CPU rapidly from one user/program to the next, each
user is given the impression that he/she has his/her own CPU, whereas actually
one CPU is being shared among many users.
7. Multiprogramming
Sharing the processor, when two or more programs reside in memory at the same
time, is referred as multiprogramming. Multiprogramming assumes a single
shared processor. Multiprogramming increases CPU utilization by organizing jobs
so that the CPU always has one to execute.
The following figure shows the memory layout for a multiprogramming system.
An OS does the following activities related to multiprogramming.
The operating system keeps several jobs in memory at a time.
This set of jobs is a subset of the jobs kept in the job pool.
The operating system picks and begins to execute one of the jobs in the
memory.
Multiprogramming operating systems monitor the state of all active
programs and system resources using memory management programs to
ensures that the CPU is never idle, unless there are no jobs to process.
Advantages
High and efficient CPU utilization.
User feels that many programs are allotted CPU almost simultaneously.
Disadvantages
CPU scheduling is required.
To accommodate many jobs in memory, memory management is required.
10. Multiprocessor operating systems
Multiprocessor operating systems are used in operating systems to boost the
performance of multiple CPUs within a single computer system. Multiple CPUs
are linked together so that a job can be divided and executed more quickly.
When a job is completed, the results from all CPUs are compiled to provide the
final output.
11. Embedded Operating system
All Embedded Systems are task specific. They mostly do a particular task on
loop/repeatedly for their entire lifetime. These systems are designed to execute
their task within a particular time interval, and thus they have to be fast enough
to be up to their time limit.
They have little or no user interface like a fully automatic washing machine does
its task fully once its programmed is set and stops after its work is finished with
almost no user interface.They are built to achieve a particularly good efficiency
level. They are very small in size operating system, need little power
These systems can't at all be upgraded or updated. Thus, they must be really
high on efficiency and reliability as they can't be updated.
Advantages
The advantages of embedded operating system are as follows −
Portable
Much faster than other operating systems
Less Hardware requirement
Highly Predictable
Disadvantages
The disadvantages of embedded operating system are as follows −
Less optimization
High modification is required
Customization is time taking process
Differences between time-sharing and the real-time operating system.
Features Time-sharing Real-time Operating System
Definition A Time-sharing system allows A Real-time operating system
several users to use a completes a task within a
computer system from various specific time.
locations simultaneously.
Computer Users may share the resources Resources are allotted to a
Resources between the users. process for a fixed amount of
time before reallocating to
another process.
Switching A switching method/function is The switching
available. method/function is not
available.
Modification Any modification may be Any modification may not be
the program possible in the program. possible in the program.
Response The response is generated The user must get the
within the second. response within the specified
time constraint.
Process It runs multiple applications It runs only a single
deals simultaneously. application simultaneously.
Basic Its focus is on responding It focuses on completing a
quickly to a request. computer task before the
deadline.
Difference between Multiprogramming and Multi-tasking
S.no Multiprogramming Multi-tasking
It includes the single CPU to It uses multiple tasks for the task
1.
execute the program. allocation.
Concept of Context Switching is Concept of Context Switching and
2.
used. Time Sharing is used.
The processor is typically used in time
In multiprogrammed system, the sharing mode. Switching happens
operating system simply switches when either allowed time expires or
3.
to, and executes, another job where there other reason for current
when current job needs to wait. process needs to wait (example
process needs to do IO).
In multi-tasking also increases CPU
Multi-programming increases CPU
4. utilization, it also increases
utilization by organizing jobs .
responsiveness.
The idea is to further extend the CPU
The idea is to reduce the CPU idle
5. Utilization concept by increasing
time for as long as possible.
responsiveness Time Sharing.
It uses job scheduling algorithms Time sharing mechanism is used so
6. so that more than one program that multiple tasks can run at the
can run at the same time. same time.
In community edition, personalized Promotions, personalized shopping
7. shopping experiences is not experiences can be displayed in
created. enterprise edition products.
8. Execution of process takes more Execution of process takes less time.
S.no Multiprogramming Multi-tasking
time.
Difference between Multiprocessing and Multiprogramming:
Multiprocessing Multiprogramming
The availability of more than one
The concurrent application of more
processor per system, that can execute
than one program in the main memory
several set of instructions in parallel is
is known as multiprogramming.
known as multiprocessing.
The number of CPU is more than one. The number of CPUs is one.
It takes less time for job processing. It takes more time to process the jobs.
In this, more than one process can be In this, one process can be executed at
executed at a time. a time.
It is tightly couped .sychronization is
No sychronization is there
there in multiprocessing.
The number of users is can be one or
The number of users is one at a time.
more than one.
Throughput is maximum. Throughput is less.
Its efficiency is maximum. Its efficiency is Less.
Operating System Services
An operating system is software that acts as an intermediary between the user
and computer hardware. It is a program with the help of which we are able to
run various applications. It is the one program that is running all the time. Every
computer must have an operating system to smoothly execute other programs.
The OS coordinates the use of the hardware and application programs for
various users. It provides a platform for other application programs to work. The
operating system is a set of special programs that run on a computer system that
allows it to work properly. It controls input-output devices, execution of
programs, managing files, etc.
Services of Operating System
Program execution
Input Output Operations
Communication between Process
File Management
Memory Management
Process Management
Security and Privacy
Resource Management
User Interface
Networking
Error handling
Time Management
Program Execution
It is the Operating System that manages how a program is going to be executed.
It loads the program into the memory after which it is executed. The order in
which they are executed depends on the CPU Scheduling Algorithms. A few
are FCFS, SJF, etc. When the program is in execution, the Operating System
also handles deadlock i.e. no two processes come for execution at the same time.
The Operating System is responsible for the smooth execution of both user and
system programs. The Operating System utilizes various resources available for
the efficient running of all types of functionalities.
Input Output Operations
Operating System manages the input-output operations and establishes
communication between the user and device drivers. Device drivers are software
that is associated with hardware that is being managed by the OS so that the
sync between the devices works properly. It also provides access to input-output
devices to a program when needed.
Communication Between Processes
The Operating system manages the communication between processes.
Communication between processes includes data transfer among them. If the
processes are not on the same computer but connected through a computer
network, then also their communication is managed by the Operating System
itself.
File Management
The operating system helps in managing files also. If a program needs access
to a file, it is the operating system that grants access. These permissions include
read-only, read-write, etc. It also provides a platform for the user to create, and
delete files. The Operating System is responsible for making decisions regarding
the storage of all types of data or files, i.e, floppy disk/hard disk/pen drive, etc.
The Operating System decides how the data should be manipulated and stored.
Memory Management
Imagine a cricket team with limited number of player. The team manager (OS)
decide whether the upcoming player will be in playing 11 ,playing 15 or will not
be included in team, based on his performance. In the same way, OS first check
whether the upcoming program fulfill all requirement to get memory space or
not, if all things good, it checks how much memory space will be sufficient for
program and then load the program into memory at certain location. And thus , it
prevents program from using unnecessary memory.
Process Management
Let’s understand the process management in unique way. Imagine, our kitchen
stove as the (CPU) where all cooking (execution) is really happen and chef as
the (OS) who uses kitchen-stove(CPU) to cook different dishes(program). The
chef(OS) has to cook different dishes(programs) so he ensure that any particular
dish(program) does not take long time(unnecessary time) and all
dishes(programs) gets a chance to cooked(execution) .The chef(OS) basically
scheduled time for all dishes(programs) to run kitchen(all the system) smoothly
and thus cooked(execute) all the different dishes(programs) efficiently.
Security and Privacy
Security : OS keep our computer safe from an unauthorized user by adding
security layer to it. Basically, Security is nothing but just a layer of
protection which protect computer from bad guys like viruses and hackers.
OS provide us defenses like firewalls and anti-virus software and ensure
good safety of computer and personal information.
Privacy : OS give us facility to keep our essential information hidden like
having a lock on our door, where only you can enter and other are not
allowed . Basically , it respect our secrets and provide us facility to keep it
safe.
Resource Management
System resources are shared between various processes. It is the Operating
system that manages resource sharing. It also manages the CPU time among
processes using CPU Scheduling Algorithms. It also helps in the memory
management of the system. It also controls input-output devices. The OS also
ensures the proper use of all the resources available by deciding which resource
to be used by whom.
User Interface
User interface is essential and all operating systems provide it. Users either
interacts with the operating system through the command-line interface or
graphical user interface or GUI. The command interpreter executes the next
user-specified command.
Networking
This service enables communication between devices on a network, such as
connecting to the internet, sending and receiving data packets, and managing
network connections.
Error Handling
The Operating System also handles the error occurring in the CPU, in Input-
Output devices, etc. It also ensures that an error does not occur frequently and
fixes the errors. It also prevents the process from coming to a deadlock. It also
looks for any type of error or bugs that can occur while any task. The well-
secured OS sometimes also acts as a countermeasure for preventing any sort of
breach of the Computer System from any external source and probably handling
them.
Time Management
Imagine traffic light as (OS), which indicates all the cars(programs) whether it
should be stop(red, start(yellow),move(green) and this light (control) changes
after a certain interval of time at each side of the road(computer system) so that
the cars(program) from all side of road move smoothly without traffic.
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 −
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.
Types of System Calls
There are mainly five types of system calls:
Process Control: These system calls deal with processes such as process creation,
process termination etc.
File Management: These system calls are responsible for file manipulation such
as creating a file, reading a file, writing into a file etc.
Device Management: These system calls are responsible for device manipulation
such as reading from device buffers, writing into device buffers etc.
Information Maintenance: These system calls handle information and its transfer
between the operating system and the user program.
Communication: These system calls are useful for Inter-Process Communication.
They also deal with creating and deleting a communication connection.
Some of the examples of all the above types of system calls in Windows and Unix are given as follows −
Types of System Calls Windows Linux
CreateProcess() fork()
Process Control ExitProcess() exit()
WaitForSingleObject() wait()
File Management CreateFile() open()
Types of System Calls Windows Linux
ReadFile() read()
WriteFile() write()
CloseHandle() close()
SetConsoleMode() ioctl()
Device Management ReadConsole() read()
WriteConsole() write()
GetCurrentProcessID() getpid()
Information Maintenance SetTimer() alarm()
Sleep() sleep()
CreatePipe() pipe()
Communication CreateFileMapping() shmget()
MapViewOfFile() mmap()
open()
The open() system call is used to provide access to a file in a file system.
This system call allocates resources to the file and provides a handle that the
process uses to refer to the file. A file can be opened by multiple processes
at the same time or be restricted to one process. It all depends on the file
organisation and file system.
read()
The read() system call is used to access data from a file that is stored in the
file system. The file to read can be identified by its file descriptor and it
should be opened using open() before it can be read. In general, the read()
system calls takes three arguments i.e. the file descriptor, buffer which stores
read data and number of bytes to be read from the file.
write()
The write() system calls writes the data from a user buffer into a device such
as a file. This system call is one of the ways to output data from a program.
In general, the write system calls takes three arguments i.e. file descriptor,
pointer to the buffer where data is stored and number of bytes to write from
the buffer.
close()
The close() system call is used to terminate access to a file system. Using
this system call means that the file is no longer required by the program and
so the buffers are flushed, the file metadata is updated and the file resources
are de-allocated.
Features of System Calls
Interface: System calls provide a well-defined interface between user
programs and the operating system. Programs make requests by calling
specific functions, and the operating system responds by executing the
requested service and returning a result.
Protection: System calls are used to access privileged operations that are
not available to normal user programs. The operating system uses this
privilege to protect the system from malicious or unauthorized access.
Kernel Mode: When a system call is made, the program is temporarily
switched from user mode to kernel mode. In kernel mode, the program has
access to all system resources, including hardware, memory, and other
processes.
Context Switching: A system call requires a context switch, which involves
saving the state of the current process and switching to the kernel mode to
execute the requested service. This can introduce overhead, which can
impact system performance.
Error Handling: System calls can return error codes to indicate problems
with the requested service. Programs must check for these errors and handle
them appropriately.
Synchronization: System calls can be used to synchronize access to shared
resources, such as files or network connections. The operating system
provides synchronization mechanisms, such as locks or semaphores, to
ensure that multiple programs can access these resources safely.
Operating System Evolution
Operating system is divided into four generations, which are explained as
follows −
First Generation (1945-1955)
The first generation of the operating system was used in the
year 19451945 to 19551955 during the time of electronic computing systems
development. It was the era of mechanical computing systems where the users or
the programmers used to provide the instructions (through punch cards, paper tape,
and magnetic tape, etc.) and the computer had to follow them. Now, due to the
human intervention, the process was very slow and there were chances of human
mistakes.
We can say that there is no operating system at that time and users used to give the
programs to the computer system itself. So, less speed and more errors were the
first-generation operating systems' drawbacks.
Second Generation (1955-1965)
The second generation of the operating system was used from the
year 19551955 to 19651965 during the time of batch operating system
development. During the second generation phase, the users used to prepare their
instructions (tasks or jobs) in the form of jobs on an off-line device like punch
cards and submits them to the computer operator. Now, out of these punch cards
(these punch cards were tabulated into instructions for computers), similar punch
cards of jobs were grouped and run as a group to speed up the entire process. The
jobs consisted of program and input data along with the control instructions. The
main task of the programmer or developer was to create jobs or programs and then
hand them over to the operator in the form of punch cards. Now, it was the duty of
an operator to sort the programs with similar requirements into batches.
Some major drawbacks of the second generation operating system were:
We could not set the priority of the jobs as jobs were scheduled only basis of
similarities among the jobs.
The CPU was not utilized to its max potential as the CPU becomes idle
(when the operator was loading jobs).
Third Generation (1965-1980)
The third generation of the operating system was used in the
year 19651965 to 19801980 during the time of multiprogramming operating
system development. The third generation operating system was developed to
serve more than one user at a time (multi-users). During this period, users were
able to communicate with the operating systems with the help of a software
called command line interface. So, the computers became multi-user and
multiprogramming.
Fourth Generation (1980-Now)
The fourth generation of the operating system is being in from the
year 19801980 till now. Before the evolution of the fourth generation of the
operating system, the users were able to communicate with the operating system
but with the help of command line interfaces, punch cards, magnetic tapes, etc. So,
the user had to provide commands (that needed to be remembered) which became
hectic.
So, the fourth generation of operating systems came into existence with the
development of GUI (Graphical User Interface). The GUI made the user
experience more convenient.
This 4th generation can be subdivided into further three categories:
Networked Systems (1980s to 1990s): This era witnessed the proliferation
of networked computing environments, enabling multiple computers to
communicate and share resources over a network.
Mobile Operating Systems (Late 1990s to Early 2000s): The late 20th
century and early 21st century saw the emergence of mobile operating
systems, specifically designed for handheld devices. This development
fundamentally changed how we interacted with technology.
AI Integration (2010s to ongoing): In recent years, operating systems have
integrated Artificial Intelligence (AI) technologies. This has led to more
intelligent and adaptive computing experiences.
We can also terminate the fourth generation operating system era the era of the
distributed operating systems. Now, the operating systems can be found in a
mobile devices, smartwatches, fitness bands, smart glasses, VR gears, and so on.
We are now surrounded by various versions of the operating system.