Chapter 1: Introduction
Operating system and functions:
• An operating system (OS) is a collection of software that manages computer
hardware resources and provides common services for computer programs.
• Examples: Windows, Linux, Unix and Mac OS, etc.,
• 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.
For example:
• A government manages rules, security, and resources in a country.
• Similarly, an OS manages files, memory, and processes in a computer
Fig: Abstract View of Components of Computer System
From Figure, 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
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
its use among the various application programs for the different users.
An operating System is a layer of software on a bare hardware machine that
performs two basic functions:
i. Resource management.
ii. Virtual machine management
1. Resource Management
A computer system consists of various resources such as CPU, memory, disks, printers, and I/O
devices.
The Operating System (OS) acts as a resource manager.
It allocates these resources to different programs in a controlled and fair manner.
Since multiple programs may run at the same time, the OS decides how much CPU time and
memory each program gets.
This ensures efficient utilization of system resources.
2. Virtual Machine Management
The Operating System provides a virtual machine view of the computer.
It hides the complex details of hardware from users and application programs.
Each program appears to run on its own virtual CPU, memory, and storage, even though
resources are shared.
The OS organizes data into files and provides simple operations such as read, write, save,
and delete.
This makes the system easy to use and safe for users.
Fig: Operating system turns ugly hardware into beautiful abstractions
The Operating System (OS) hides complex hardware details and provides a simple way for
users and programs to interact with the computer.
It makes difficult tasks like handling storage, memory, and processing easier by offering
a user-friendly interface.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
The OS acts like a virtual machine, making the computer easier to use compared to its
raw hardware.
Evolution of Operating System
Operating system has been evolving through years.
Generation of computers to see what their operating system were like.
Generation Years Electronic devices Types of OS /
used Systems used
First 1945–1955 Vacuum tubes No OS, Plug
boards, Machine
language
Second 1955–1965 Transistors Batch Operating
Systems
Third 1965–1980 ICs Multiprogrammin
g OS, Time-
sharing OS
Fourth 1980–Present LSI / VLSI Personal
Computer OS,
GUI OS
(Windows,
UNIX, Linux)
Types of Operating System
1. Batch Processing System:
In a Batch System, users do not interact with the computer directly. Instead, they submit jobs
(programs + data) to be processed automatically.
Jobs are executed one after another in the order they arrive (FIFO - First In, First Out).
Only one program runs at a time, so managing memory is simple.
Since only one program is running, there is no need for complex device management or file
handling. Everything happens in a straightforward way.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Advantages:
– A lot of manual work is reduced.
– CPU’s idle time is reduced.
– Execution becomes fast and well managed.
– Multiple users can share the batch systems.
Disadvantages:
– Lack of interaction between user and job.
– Difficult to provide the desired priority.
– Starvation: Different jobs in a single batch might take different
amounts of time in execution. This might lead to starvation of some
jobs. Suppose there are 4 jobs in a batch and the first job takes too
long to execute then the other three jobs in the same batch will have to
wait for long until the first one is completed.
2. Multiprocessing System:
A computer’s capability to process more than one task simultaneously is
called multiprocessing.
A multiprocessing operating system is capable of running many programs
simultaneously, and most modern network operating systems (NOSs)
support multiprocessing.
These operating systems include Windows NT, 2000, XP, and UNIX.
A multiprocessing system uses more than one processor to process any given
workload, increasing the performance of a system’s application environment
beyond that of a single processor’s capability.
Types of Multiprocessing:
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Symmetric Multiprocessing (SMP):
o All CPUs are treated equally, sharing access to memory and I/O resources.
o This is the most common form of multiprocessing in modern systems.
Asymmetric Multiprocessing (AMP):
o One CPU acts as a master, assigning tasks to other subordinate CPUs.
o This model is less common in general-purpose systems.
Advantage:
– Increase throughput ( amount of work completed in a unit of time)
– Increased reliability
Disadvantage:
– If one processor fails then it will affect in the speed.
– Multiprocessor systems are expensive.
– Complex OS is required.
– Large main memory required.
3. Time sharing(Multitasking) System:
A time sharing system is an operating system technique that allows multiple users or multiple
processes to share the CPU simultaneously by dividing CPU time into very small units called
time slices (quantum).
Instead of one job finishing before another starts, the CPU rapidly switches between tasks,
giving each one a short turn. To users, it feels like everything is running at the same time.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Advantage:
– Response time for each task is reduced a lot.
– Provides advantage of quick response
– All the processes can access CPU for fair amount of time
Disadvantage:
– Reliability issues
– Security and integrity questions of user data and programs
– Data communication issues
Example of Time sharing system: Time sharing systems are all around us. For
example, while we are using our smartphone we can listen songs, search
something, view pictures and various notifications appear side by side. All this is
enabled by time sharing operating system only.
4. Real time operating system:
A Real-Time Operating System (RTOS) is a special type of OS that runs programs on
time and within strict deadlines.
It works just like a normal OS but has extra features to ensure tasks are completed on
time.
It is used in systems where timing is very important, like airplane controls, medical
devices, and industrial machines.
Based on the strictness of the time constraints, real-time operating systems are classified as:
Hard real-time operating systems:
These operating systems are meant for the applications where time
constraints are very strict and even the shortest possible delay is not
acceptable.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
These are mainly present in the life saving systems like automatic parachutes
or air bags which are required to be readily available in case of any accident.
Soft real-time operating systems:
These kinds of operating systems serve the real-time applications in
which the time constraints are somewhat less strict and a little amount of
delay is acceptable.
For example, Live TV broadcast, Video Conferencing etc. Even if some
delay is there, nothing catastrophic is going to happen.
Advantages:
– Maximum consumption
– Error free
– 24-7 systems
Disadvantages:
– Expensive
– Limited tasks
– Low multitasking
– Use of complex algorithms
Examples of real time systems: Air traffic control system, missile systems, Robots etc.
5. Network Operating Systems:
Run on a server and manage data, users, groups, security, applications, and networking
functions.
Allow multiple users to share resources like files, printers, and applications.
Mainly there are two types of network operating.
Peer-to-peer network operating systems: ₋
Computers share files and resources directly without a central server.
Every computer is equal and can send/receive files.
Best suited for small to medium local area networks (LANs).
Client/server network operating systems: ₋
A system where a central server manages files, applications, and security for connected
computers (clients).
The server controls access to files, applications, and security settings.
Clients (workstations) connect to the server to use these resources .
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Many users can share files and programs at the same time, no matter where they are.
Advantages:
– Highly Stable centralized servers
- Security concerns are handled through servers
– Server access are remotely possible
Disadvantages:
– Servers are costly
– Users has to depend on central location for most operations
– Maintenance and updates are required regularly.
Examples of Network operating systems: Microsoft Windows Server 2003, Microsoft
Windows Server 2008, UNIX, Linux, Mac OS X
6. Distributed Operating System:
A distributed operating system is an OS that runs on multiple independent computers
connected via a network.
Its main purpose is to make the collection of machines appear as a single unified system
to users.
The computers communicate with each other using a shared communication network
(LAN, WAN, or other networks).
Advantage:
– Sharing of resources
– Reliability
– Communication
– Computation speedup
Disadvantage:
– Expensive
– Failure of main network will stop the entire communication
Examples of Distributed operating systems: Amoeba, Mach, Locus etc.
Functions of an Operating System
An Operating System (OS) manages computer hardware and software resources and provides
services to users.
1. Process Management
A process is a program that is currently running. Process management is the job of the operating
system to manage many running programs at the same time. It decides which process runs,
pauses, or stops, and makes sure all processes use the CPU and other resources properly from
start to end.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Main functions:
Scheduling: Decides which process gets CPU time
Synchronization: Ensures correct order of execution and avoids conflicts
Deadlock Handling: Prevents or resolves deadlocks
Inter-Process Communication (IPC): Allows processes to share data
2. Memory Management
Memory management is the function of the operating system that decides how memory is given
to programs, how it is used, and how it is freed when a program finishes.
Main functions:
Allocation and deallocation of memory
Virtual Memory: Uses disk as extra memory
Reduces memory fragmentation
3. File System Management
File system management is the function of the operating system that organizes files, gives them
names, and controls how they are stored and accessed.
Main functions:
Creating, reading, writing, and deleting files
Managing directories
Maintaining file attributes (name, size, permissions)
Supporting different file access methods
4. Device Management (I/O System)
Device management is the function of the operating system that controls how the computer
communicates with hardware devices like keyboard, printer, and disk.
Main components:
Device Drivers: Interface between hardware and OS
Buffering and Caching: Improves I/O performance
5. Protection and Security
Protection and security are functions of the operating system that ensure only authorized users
and programs can access system resources and keep data safe from misuse or attacks.
Main functions:
Access control for users and processes
User authentication
Protection of files, memory, and devices
Defense against malware and unauthorized access
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Operating System Services
1. System Call:
A system call is a mechanism used by an application program to request services from
the operating system.
It provides a programmatic way to switch execution from user mode to kernel mode in
order to access the operating system kernel’s functionality.
Computers have two modes:
User mode: Where normal programs run. They cannot touch hardware directly.
Kernel mode: Where the OS runs. It can access hardware and perform critical tasks.
They use special machine-level instructions that cause the processor to change mode
from user mode to kernel mode.
Types of System Calls in OS
There are several hundred system calls, which can be roughly categorized into five types:
1. Process control: These include CreateProcess, ExitProcess, fork(), exec(), exit().
fork() – creates a child process identical to the parent.
exec() – replaces the current process with a new program .
wait() – makes the parent process wait for the child to finish .
getpid() – returns the process ID of the current process .
getppid() – returns the parent process ID .
exit() – terminates a process with an exit status .
2. File management: These include CreateFile, ReadFile, DeleteFile, open(), read(),
write().
open() – opens a file for reading/writing.
read() – reads data from a file into a buffer .
write() – writes data from a buffer into a file .
close() – closes an open file.
3. Device management: These system calls are used to request, read from, write to, and
release hardware devices. These include read(), write(), ioctl().
read() / write() – perform input/output operations on devices.
ioctl() – controls device-specific operations.
4. Information maintenance: These system calls are used to get or set system and
process information. This includes time(), getpid().
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
time() – returns the current system time.
getpid() – returns the process ID of the calling process.
5. Communication: These system calls are used for inter-process communication
(IPC).This includes CreatePipe, send(), receive().
CreatePipe / pipe() – creates a communication channel between
processes.
send() / receive() – used to exchange data between processes.
Shell and Kernels
Shell and the kernel are the parts of this Operating system.
These both parts are used for performing any operation on the system.
The shell accepts commands from the user, interprets them, and
communicates with the kernel using system calls.
Human Command Shell → Kernel → Machine Language (Hardware).
Kernel is the heart of the operating system. It is the basis for the proper
functioning of the entire system. Kernel performs a variety of tasks including
process management, managing hardware devices and handling interrupts.
Furthermore, it performs memory management, file handling and task
scheduling. A system call is a request by a process to the kernel. The kernel
manages these system calls and other resources.
It decides which process should be allocated to processor to execute and
which process should be kept in main memory to execute. It basically acts as
an interface between user applications and hardware. The major aim of
kernel is to manage communication between software i.e. user-level
applications and hardware i.e., CPU and disk memory.
It is a software interface that's often a command line interface that enables
the user to interact with the computer.
Shell Kernel
1. It allows users to communicate 1. It controls all the tasks of users.
with kernels.
2. It is the interface between user 2. It is the core of operating system.
and kernels.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
4. Shell commands like ls, mkdir and 4. It performs process management.
many more can be used to request to
complete the specific operation to the
OS.
5. It is the outer layer of OS. 5. It is inner layer of OS.
6. Types: C shell, Bourne Shell, Korn 6. Types: monolithic kernel, micro
Shell kernel
7. A shell interacts with all of its 7. A kernel interacts with the
users and then interprets into a hardware directly because it
language that is understandable by accepts the machine-understandable
the machine. language from the available shell.
Operating System (OS) Kernel
It is a type of system software that manages It is the core component of the OS that
computer resources. directly interacts with hardware.
Provides an interface between the user and Provides an interface between
computer hardware. applications and hardware.
Responsible for overall system management: Responsible for low-level management of
process, memory, I/O, security, and file systems. CPU, memory, and device I/O.
Cannot function without a kernel. The OS cannot run without the kernel.
Includes different types: Single-user, Multiuser, Types include Monolithic, Microkernel,
Real-time, Distributed OS. and Hybrid kernels.
Operating System Structure:
The OS structure defines the interconnection of system components and their interface
with the kernel.
The system can be partitioned into modules, where each module is a well-defined portion
of the OS with specific inputs, outputs, and functions.
Some common system structures are:
– Monolithic System
– Layered System
– Microkernels
– Virtual Machine Approach
1. Monolithic System:
Monolithic kernel is an operating system architecture where the entire
operating system is working in kernel space. This increases the size of the
kernel as well as the operating system.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
All the basic services of OS like process management, file management,
memory management, exception handling, process communication etc. are
all present inside the kernel only.
Advantages of Monolithic Kernel:
The execution of the monolithic kernel is quite fast as the services such as
memory management, file management, process scheduling, etc., are
implemented under the same address space.
A process runs completely in a single address space in the monolithic kernel.
Communication between components: All the components can directly
communicate with each other and also with the kernel.
Disadvantages of Monolithic Kernel:
If any service fails in the monolithic kernel, it leads to the failure of the entire system.
To add any new service, the entire operating system needs to be modified by the user.
2. Layered System:
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
This is an important architecture of operating system which is meant to
overcome the disadvantages of early monolithic systems. In this approach,
OS is split into various layers such that all the layers perform different
functionalities.
Each layer can interact with the one just above it and the one just below it.
Lowermost layer which directly deals with the bare hardware is mainly
meant to perform the functionality of I/O communication and the uppermost
layer which is directly connected with the application program acts as an
interface between user and operating system.
Advantages of Layered architecture:
function of one layer will not affect the entire operating system
Easier testing and debugging due to isolation among the layers.
Adding new functionalities or removing outdated ones is very easy.
Disadvantages of Layered architecture:
It is not always possible to divide the functionalities, many a times they are
inter-related and can’t be separated.
Sometimes, a large no. of functionalities is there and number of layers
increase greatly. This might lead to degradation in performance of the
system.
Example of Layered Architecture: Microsoft Windows NT operating System
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
3. Microkernels:
As compare to monolithic kernel, in microkernels almost all the function and services are
removed from the kernel mode and relocated into the user mode. As a result the kernel size
is minimum. Since almost all the function and services operated in user mode, here the
kernel mode does the following task only.
a. Interrupt handling
b. Low level process management
c. Message passing handling
Exchange of information among the process are done using inter process communication
(IPC). A message (i.e data) is transferred from one process to another using IPC.
Note: Synchronization:
Synchronization in an operating system refers to the coordination of multiple processes or threads to ensure correct
execution and avoid conflicts when accessing shared resources. It is essential for maintaining consistency in multi-
threaded and multi-process environment
Advantages:
Kernel is small and isolated and can hence function better
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
Expansion of the system is easier, it is simply added in the system
application without disturbing the kernel.
Disadvantages:
Providing services in a microkernel system are expensive compared to
the normal monolithic system.
The performance degraded due to inter-module communication.
4. Client Server Architecture:
Client-server architecture is a network model where multiple client computers (users)
connect to a central server to request services.
The server is a powerful computer that processes requests and sends back responses.
Clients are the user devices (PCs, phones, etc.) that ask for data or services from the server.
Examples of computer applications that use the client server model are
email, network printing, and the World Wide Web
Advantages of Client-Server Architecture
Centralization of control: access, resources and integrity of the data are
controlled by the dedicated server so that a program or unauthorized client
cannot damage the system. This centralization also facilitates task of
updating data or other resources (better than the networks P2P).
Scalability: You can increase the capacity of clients and servers separately.
Any element can be increased (or enhanced) at any time, or you can add new
nodes to the network (clients or servers).
Easy maintenance: distribute the roles and responsibilities to several stand
alone computers, you can replace, repair, upgrade, or even move a server,
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University
while customers will not be affected by that change (or minimally affect).
This independence of the changes is also known as encapsulation.
Disadvantages of Client-Server Architecture
Traffic congestion has always been a problem in the paradigm of C / S.
When a large number of simultaneous clients send requests to the same
server might cause many problems for this (to more customers, more
problems for the server).
When a server is down, customer requests cannot be met.
Virtual Machine:
A virtual machine does not own it’s hardware, it uses the resources of host computer.
Fundamental idea behind a VM is to abstract the H/W of a single component into several
different execution environments, there by creating the illusion that each separate
execution environment is running its own private component.
To get it easily, virtual machines allow you to run an operating system in an app window
on your desktop that behaves like a full, separate computer.
VM is software that allow you to run many operating systems without risking you host
operating systems.
Compiled By: [Link] Kumar Bisht,Assistant Professor,Farwestern University