Operating System Unit 1
Operating System Unit 1
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.
Advantages:
It increases the throughput of the system.
As it has several processors, so, if one processor fails, we can proceed with
another processor.
Disadvantages:
Due to the multiple CPU, it can be more complex and somehow difficult to
understand.
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 ensures 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 respects our secrets and provides 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
interface 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.
SYSTEM CALL
A system call is a programmatic way in which a computer program
requests a service from the kernel of the operating system it is executed on. A
system call is a way for programs to interact with the operating system. A
computer program makes a system call when it makes a request to the operating
system’s kernel. System call provides the services of the operating system to the
user programs via Application Program Interface (API). It provides an interface
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.
How does System Call Work?
User need special resources: Sometimes programs need to do some
special things which can’t be done without the permission of OS like
reading from a file, writing to a file, getting any information from the
hardware or requesting a space in memory.
Program makes a system call request: There are special predefined
instructions to make a request to the operating system. These instructions
are nothing but just a “system call”. The program uses these system calls
in its code when needed.
Operating system sees the system call :When the OS sees the system call
then it recongnises that the program need help at this time so it temporarily
stop the program execution and give all the control to special part of itself
called ‘Kernel’ . Now ‘Kernel’ solves the need of program.
Operating system performs the operations: Now the operating system
perform the operation which is requested by program.
Example: reading content from a file etc.
Operating system give control back to the program: After performing the
special operation, OS give control back to the program for further
execution of program .
open(): Opens a file for reading or writing. A file could be of any type like
text file, audio file etc.
read(): Reads data from a file. Just after the file is opened through open()
system call, then if some process want to read the data from a file, then it
will make a read() system call.
write(): Writes data to a file. Whenever the user makes any kind of
modification in a file and saves it, that’s when this is called.
close(): Closes a previously opened file.
seek(): Moves the file pointer within a file. This call is typically made when
we the user tries to read the data from a specific position in a file. For
example, read from line – 47. Than the file pointer will move from line 1 or
wherever it was previously to line-47.
2. Process Control
These types of system calls deal with process creation, process termination,
process allocation, deallocation etc. Basically manages all the process that are a
part of OS.
fork(): Creates a new process (child) by duplicating the current process
(parent). This call is made when a process makes a copy of itself and the
parent process is halted temporarily until the child process finishes its
execution.
exec(): Loads and runs a new program in the current process and replaces
the current process with a new process. All the data such as stack,
register, heap memory everything is replaced by a new process and this is
known as overlay. For example, when you execute a java byte code using
command – java “filename”. Then in the background, exec() call will be
made to execute the java file and JVM will also be executed.
wait(): The primary purpose of this call is to ensure that the parent process
doesn’t proceed further with its execution until all its child processes have
finished their execution. This call is made when one or more child
When two or more processes are required to communicate, then various IPC
mechanisms are used by the OS which involves making numerous system calls.
Some of them are:
pipe(): Creates a unidirectional communication channel between
The device management system calls are used to interact with various
peripheral devices attached to the PC or even the management of the current
device.
SetConsoleMode(): This call is made to set the mode of console (input or
output). It allows a process to control various console modes. In windows,
it is used to control the behaviour of command line.
WriteConsole(): It allows us to write data on console screen.
ReadConsole(): It allows us to read data from console screen (if any
arguments are provided).
open(): This call is made whenever a device or a file is opened. A unique
file descriptor is created to maintain the control access to the opened file or
device.
close(): This call is made when the system or the user closes the file or
device.
Implementation:
Implementation is the process of writing source code in a high-level
programming language, compiling it into object code, and then interpreting
Simple/Monolithic structure
Such operating systems do not have well-defined structures and are small,
simple, and limited. The interfaces and levels of functionality are not well
separated. MS-DOS is an example of such an operating system. In MS-DOS,
application programs are able to access the basic I/O routines. These types of
operating systems cause the entire system to crash if one of the user programs
fails.
Advantages of Simple/Monolithic structure
It delivers better application performance because of the few interfaces
between the application program and the hardware.
It is easy for kernel developers to develop such an operating system.
Disadvantages of Simple/Monolithic structure
The structure is very complicated, as no clear boundaries exist between
modules.
It does not enforce data hiding in the operating system.
Micro-kernel Structure
This structure designs the operating system by removing all non-essential
components from the kernel and implementing them as system and user
programs. This result in a smaller kernel called the micro-kernel. Advantages of
this structure are that all new services need to be added to user space and does
not require the kernel to be modified. Thus it is more secure and reliable as if a
service fails, then rest of the operating system remains untouched. Mac OS is an
example of this type of OS.
Advantages of Micro-kernel structure
It makes the operating system portable to various platforms.
As micro kernels are small so these can be tested effectively.
Disadvantages of Micro-kernel structure
Increased level of inter module communication degrades system
performance.
Hybrid-Kernel Structure
Hybrid-kernel structure is nothing but just a combination of both monolithic-
kernel structure and micro-kernel structure. Basically, it combines properties of
both monolithic and micro-kernel and make a more advance and helpful
approach. It implement speed and design of monolithic and modularity and
stability of micro-kernel structure.
Advantages of Hybrid-Kernel Structure
It offers good performance as it implements the advantages of both
structure in it.
It supports a wide range of hardware and applications.
It provides better isolation and security by implementing micro-kernel
approach.
It enhances overall system reliability by separating critical functions into
micro-kernel for debugging and maintenance.
Disadvantages of Hybrid-Kernel Structure
It increases overall complexity of system by implementing both structure
(monolithic and micro) and making the system difficult to understand.
The layer of communication between micro-kernel and other component
increases time complexity and decreases performance compared to
monolithic kernel.
Exo-Kernel Structure
Exokernel is an operating system developed at MIT to provide application-level
management of hardware resources. By separating resource management from
protection, the exokernel architecture aims to enable application-specific
customization. Due to its limited operability, exokernel size typically tends to be
minimal.
The OS will always have an impact on the functionality, performance, and scope
of the apps that are developed on it because it sits in between the software and
the hardware. The exokernel operating system makes an attempt to address this
Disadvantages of Exo-kernel
A decline in consistency
Exokernel interfaces have a complex architecture.
Layered structure
An OS can be broken into pieces and retain much more control over the system.
In this structure, the OS is broken into a number of layers (levels). The bottom
layer (layer 0) is the hardware, and the topmost layer (layer N) is the user
interface. These layers are so designed that each layer uses the functions of the
lower-level layers. This simplifies the debugging process, if lower-level layers are
debugged and an error occurs during debugging, then the error must be on that
layer only, as the lower-level layers have already been debugged.
The main disadvantage of this structure is that at each layer, the data needs to
be modified and passed on which adds overhead to the system. Moreover,
careful planning of the layers is necessary, as a layer can use only lower-level
layers. UNIX is an example of this structure.
Advantages of Layered structure
Based on our needs, a virtual machine abstracts the hardware of our personal
computer, including the CPU, disc drives, RAM, and NIC (Network Interface
Card), into a variety of different execution contexts, giving us the impression that
each execution environment is a different computer. An illustration of it is a
virtual box.
An operating system enables us to run multiple processes concurrently while
making it appear as though each one is using a different processor and virtual
memory by using CPU scheduling and virtual memory techniques.
of the services provided by the kernel. The user apps do not have the privilege to
perform operations, so they make system calls which further requests a kernel to
provide a specific service.
Q.2: How do device management System Calls work?
Device management system calls work by allowing a certain process or a
device interact and get access to other hardware resources and perform various
operations.
Q.3: What is user mode and kernel mode?
User mode and kernel modes are two different privilege modes of a
Computer System that separates the execution of operations by the user
applications and the kernel on hardware. This separation provides security,
stability, and a level of control over system resources.
Q.4: What happens when a System Call is executed?
When a system call is executed, a context switch occurs and the computer
system switches from user mode to kernel mode and now the kernel performs
the desired operation.
Q.5: What is a software interrupt?
A software interrupt is a mechanism through which the OS performs a
context switch and transition from user mode to kernel mode. A software
interrupt use is not limited only to the system calls but it can also be made when
a high priority task is required to be executed by the CPU.
Q.6: What is a Microkernel?
A microkernel is an operating system structure that aims to keep the kernel
as small and lightweight as possible. It provides only essential services, such as
process scheduling and inter-process communication, while moving most non-
essential services, like device drivers, into user space.
Q.7: What is a Hybrid Kernel?
A hybrid kernel combines features of both monolithic and microkernels. It
includes a small kernel that handles essential services and basic hardware
interactions, while additional services, such as file systems and device drivers,
run in kernel mode but outside the core kernel.
Q.8 What is a Virtualization-based Kernel?
A virtualization-based kernel, also known as a hypervisor, is an operating
system structure that enables the execution of multiple operating systems
concurrently on the same hardware. It provides virtualized environments for
guest operating systems and manages their interactions with the underlying
hardware.