Operating System Notes
Operating System Notes
iec college
of
engineering &technology
greater noida
Unit-01
Introduction: An operating system acts as an intermediary between the user of a
computer and computer hardware. In short its an interface between computer
hardware and user.
• The purpose of an operating system is to provide an environment in
which a user can execute programs conveniently and efficiently.
• An operating system is software that manages computer hardware and
software. The hardware must provide appropriate mechanisms to ensure
the correct operation of the computer system and to prevent user
programs from interfering with the proper operation of the system.
• The operating system (OS) is a program that runs at all times on a
computer. All other programs, including application programs, run on top
of the operating system.
• It does assignment of resources like memory, processors and input /
output devices to different processes that need the resources. The
assignment of resources has to be fair and secure.
Functionalities of Operating System
• Resource Management: When multiple processes run on the system
and need different resources like memory, input/output devices, the OS
works as Resource Manager, Its responsibility is to provide hardware to
the user. It decreases the load in the system.
• Process Management: It includes various tasks like scheduling and
synchronization of processes. Process scheduling is done with the help
of CPU Scheduling algorithms . Process Synchronization is mainly
required because processes need to communicate with each other. When
processes communicate different problems arise like two processes can
update the same memory location in incorrect order.
• Storage Management: The file system mechanism used for the
management of the secondary storage like Hard
Disk. NIFS, CIFS, CFS, NFS, etc. are some file systems that are used by
operating systems to manage the storage. All the data is stored in various
tracks of Hard disks that are all managed by the storage manager.
• Memory Management: Refers to the management of primary memory,
mainly allocation and de-allocation of memory to processes. The
operating system has to keep track of how much memory has been used
and by which process. It has to decide which process needs memory
space and how much.
• Security/Privacy Management: Privacy is also provided by the
Operating system using passwords so that unauthorized applications
can’t access programs or data. For example, Windows
uses Kerberos authentication to prevent unauthorized access to data.
2
Every computer must have an operating system to run other programs. The
operating system coordinates the use of the hardware among the various system
programs and application programs for various users. It simply provides an
environment within which other programs can do useful work.
An OS is a package of some programs that runs on a computer machine, allowing
it to perform efficiently. It manages the simple tasks of recognizing input from the
keyboard, managing files and directories on disk, displaying output on the screen
and controlling peripheral devices.
Goals of Operating System
Primary Goals
The primary goals of an operating system (OS) are to provide a easy to use and
convenient environment for executing user programs.
1. User Convenience : It should be easy to use, providing a user-friendly
interface and making it simple to interact with the system.
2. Program Execution: It facilitates the execution of user programs,
providing the necessary environment and services for them to run.
Apple Macintosh
GUI-based OSs gained traction;
1980s (1984), Windows
networking features became standard.
(1985)
Function of OS
1. Process Management
Process management in operating system is about managing processes. A Process is a running
program. The life cycle of process is from the moment program start until it finishes. Operating
system makes sure each process:
• gets its turn to use the CPU
• synchronized when needed
• has access to the resources it needs, like memory, files, and input/output devices.
It also handles issues like process coordination and communication, while preventing conflicts
such as deadlocks. This way, the OS ensures smooth multitasking and efficient resource use.
Memory Management
Key Activities in Memory Management:
Main Memory Management
• Memory Allocation: Assigns memory to processes using techniques
like paging and segmentation.
• Memory Deallocation: Frees memory when no longer needed.
• Memory Protection: Prevents processes from accessing each other’s memory.
• Virtual Memory: Uses disk space as extra memory to run larger processes.
• Fragmentation: Manages wasted memory space (internal/external)
through compaction.
10
Device Management
Major components in Device Management:
Device Drivers: The operating system uses device drivers to interact with hardware devices.
There are two types of device drivers:
11
Security
• Access Control: The operating system ensures that processes and users can only
access resources they are authorized to. This is achieved through mechanisms like
memory-addressing hardware (which keeps processes within their own address space)
and timer interrupts (which prevent processes from monopolizing the CPU).
12
• User Authentication: A system identifies users through user IDs (UIDs) or Security IDs
(SIDs). During login, the operating system verifies the user’s credentials, ensuring that
only authorized users can access their data or system resources.
• Resource Protection: Mechanisms like file protection (ensuring only authorized users
can access or modify files) and device protection (restricting direct access to device-
control registers) ensure the integrity of system resources, preventing unauthorized or
harmful use.
• Security Against Attacks: Security mechanisms defend against external threats like
viruses, worms, denial-of-service attacks, and identity theft. These attacks can misuse
system resources, steal sensitive data, or disrupt system operation. The OS works to
prevent these threats and minimize damage.
6. Additional Functions of the Operating System
Beyond core tasks like process and memory management, operating systems also focus on
system performance, resource utilization and error detection. These functions ensure smooth
operation, efficient resource allocation and system reliability.
• Control Over System Performance: The OS monitors system performance by recording
delays between service requests and system responses. This helps identify bottlenecks
and optimize resource usage, ensuring efficient system operation.
• Job Accounting: The OS keeps track of time and resources used by various tasks and
users. This information is valuable for auditing, billing, and optimizing resource
allocation among users and applications.
• Error-Detecting Aids: The OS produces dumps, traces, error messages, and other
debugging aids to detect and diagnose errors. This proactive approach helps maintain
system stability and aids in troubleshooting issues.
13
14
Multi Programming
15
Advantages of Time-Sharing OS
• Each task gets an equal opportunity.
• Fewer chances of duplication of software.
• CPU idle time can be reduced.
• Resource Sharing: Time-sharing systems allow multiple users to
share hardware resources such as the CPU, memory, and
peripherals, reducing the cost of hardware and increasing
efficiency.
• Improved Productivity: Time-sharing allows users to work
concurrently, thereby reducing the waiting time for their turn to
use the computer. This increased productivity translates to more
work getting done in less time.
• Improved User Experience: Time-sharing provides an interactive
environment that allows users to communicate with the computer
in real time, providing a better user experience than batch
processing.
Disadvantages of Time-Sharing OS
• Reliability problem.
• One must take care of the security and integrity of user
programs and data.
• Data communication problem.
16
17
18
Distributed OS
19
• These types of systems are not readily available as they are very
expensive. Not only that the underlying software is highly
complex and not understood well yet.
Examples of Distributed Operating Systems are LOCUS, etc.
Issues With Distributed Operating Systems
• Networking causes delays in the transfer of data between nodes
of a distributed system. Such delays may lead to an inconsistent
view of data located in different nodes and make it difficult to
know the chronological order in which events occurred in the
system.
• Control functions like scheduling, resource allocation, and
deadlock detection have to be performed in several nodes to
achieve computation speedup and provide reliable operation
when computers or networking components fail.
• Messages exchanged by processes present in different nodes
may travel over public networks and pass through computer
systems that are not controlled by the distributed operating
system. An intruder may exploit this feature to tamper with
messages or create fake messages to fool the authentication
procedure and masquerade as a user of the system.
6. Network Operating System
These systems run on a server and provide the capability to manage data,
users, groups, security, applications, and other networking functions.
These types of operating systems allow shared access to files, printers,
security, applications, and other networking functions over a small private
network. One more important aspect of Network Operating Systems is
that all the users are well aware of the underlying configuration, of all
other users within the network, their connections, etc., and that’s why
these computers are popularly known a tightly coupled systems.
20
These types of OSs serve real-time systems. The time interval required to
process and respond to inputs is very small. This time interval is
called response time. Real-time systems are used when there are time
requirements that are very strict like missile systems, air traffic control
systems, robots, etc.
Types of Real-Time Operating Systems
•Hard Real-Time Systems: Hard Real-Time OSs are meant for
applications where time constraints are very strict, and even the
shortest possible delay is not acceptable. These systems are built
for saving lives like automatic parachutes or airbags which are
required to be readily available in case of an accident. Virtual
memory is rarely found in these systems.
• Soft Real-Time Systems: These OSs are for applications where
time is less strict.
For more, refer to the Difference Between Hard Real-Time OS and Soft
Real-Time OS.
Advantages of RTOS
• Maximum Consumption: Maximum utilization of devices and
systems, thus more output from all the resources.
• Task Shifting: The time assigned for shifting tasks in these
systems is very less. For example, in older systems, it takes about
10 microseconds to shift from one task to another, and in the
latest systems, it takes 3 microseconds.
• Focus on Application: Focus on running applications and give
less importance to applications that are in the queue.
22
24
25
Threads
26
27
28
29
the blueprint of how an OS is organized and how its different parts interact
with each other.
Simple OS Structure
30
31
Layered OS Design
Advantages :
There are several advantages to this design :
1. Modularity : This design promotes modularity as each layer
performs only the tasks it is scheduled to perform.
2. Easy debugging : As the layers are discrete so it is very easy to
debug. Suppose an error occurs in the CPU scheduling layer, so
the developer can only search that particular layer to debug,
unlike the Monolithic system in which all the services are present
together.
3. Easy update : A modification made in a particular layer will not
affect the other layers.
4. No direct access to hardware : The hardware layer is the
innermost layer present in the design. So a user can use the
services of hardware but cannot directly modify or access it,
32
unlike the Simple system in which the user had direct access to
the hardware.
5. Abstraction : Every layer is concerned with its own functions. So
the functions and implementations of the other layers are
abstract to it.
Disadvantages :
Though this system has several advantages over the Monolithic and
Simple design, there are also some disadvantages as follows.
1. Complex and careful implementation : As a layer can access
the services of the layers below it, so the arrangement of the
layers must be done carefully. For example, the backing storage
layer uses the services of the memory management layer. So it
must be kept below the memory management layer. Thus with
great modularity comes complex implementation.
2. Slower in execution : If a layer wants to interact with another
layer, it sends a request that has to travel through all the layers
present in between the two interacting layers. Thus it increases
response time, unlike the Monolithic system which is faster than
this. Thus an increase in the number of layers may lead to a very
inefficient design.
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
33
• 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.
34
Memory Management
Let’s understand memory management by OS in simple way. 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 fulfil 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 defences 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.
35
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.
A GUI offers the user a mouse-based window and menu system as an
interface.
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)=>(simple queue), start(yellow)=> (ready
queue),move(green)=>(under execution) 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.
Kernel in Operating System
Last Updated : 24 Jan, 2025
••
•
A kernel is the core part of an operating system. It acts as a bridge between
software applications and the hardware of a computer.
• The kernel manages system resources, such as the CPU, memory,
and devices, ensuring everything works together smoothly and
efficiently.
• It handles tasks like running programs, accessing files, and
connecting to devices like printers and keyboards.
• An Operating System includes the kernel as its core, but also
provides a user interface, file system management, network
36
37
38
39
40
41
5. Resource Management
• Managing system resources (CPU time, disk space, network
bandwidth)
• Allocating and deallocating resources as needed
• Monitoring resource usage and enforcing resource limits
6. Security and Access Control
• Enforcing access control policies.
• Managing user permissions and authentication.
• Ensuring system security and integrity.
7. Inter-Process Communication
• Facilitating communication between processes.
• Providing mechanisms like message passing and shared memory.
Working of Kernel
• A kernel loads first into memory when an operating system is
loaded and remains in memory until the operating system is shut
down again. It is responsible for various tasks such as disk
management , task management, and memory management .
• The kernel has a process table that keeps track of all active
processes
• The process table contains a per-process region table whose
entry points to entries in the region table.
• The kernel loads an executable file into memory during the ‘exec’
system call’.
• It decides which process should be allocated to the processor to
execute and which process should be kept in the main memory to
execute. It basically acts as an interface between user applications
and hardware. The major aim of the kernel is to manage
communication between software i.e. user-level applications and
hardware i.e., CPU and disk memory.
Objectives of Kernel
• To establish communication between user-level applications and
hardware.
• To decide the state of incoming processes.
• To control disk management.
• To control memory management.
• To control task management.
43