Structure of
Operating System
Unit-1
Operating System/01CE1401
Department of Computer
Engineering
Prof. Kajal Tanchak
Contents
• Structure of Operating System
• Monolithic Kernel
• Micro-Kernel
• Layered System
• Modular System
• Virtual Machines
• Unix System Architecture
• System Calls
• Interrupts
• Hardware Interrupt
• Software Interrupt
Course Outcome
• Understanding the role of operating system with its function and services.
1. Monolithic Kernel
• The monolithic operating system controls all aspects of the operating system's
operation, including file management, memory management, device
management, and operational operations.
• The core of an operating system for computers is called the kernel (OS). All other
System components are provided with fundamental services by the kernel. The
operating system and the hardware use it as their main interface. When an operating
system is built into a single piece of hardware, such as a keyboard or mouse, the kernel
can directly access all of its resources.
Monolithic Kernel
Monolithic
Kernel
Monolithic Kernel
Advantages of Monolithic Structure:
• Because layering is unnecessary and the kernel alone is responsible for managing all operations, it is
easy to design and execute.
• Due to the fact that functions like memory management, file management, process scheduling, etc.,
are implemented in the same address area, the monolithic kernel runs rather quickly when
compared to other systems. Utilizing the same address speeds up and reduces the time required for
address allocation for new processes.
Disadvantages of Monolithic Structure:
• The monolithic kernel's services are interconnected in address space and have an impact on one
another, so if any of them malfunctions, the entire system does as well.
• It is not adaptable. Therefore, launching a new service is difficult.
2. Layered System
• The layered structure approach breaks up the operating system into different layers and retains
much more control on the system. 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 only.
• All the layers can be defined separately and interact with each other as required. Also, it is
easier to create, maintain and update the system if it is done in the form of layers.
Change in one layer specification does not affect the rest of the layers.
• A key problem in layered system is deciding on the ordering of the layers.(This is
critical because of the requirement that each layer can ultimately only use services provided by
layers below it so the ordering cannot have any cycles.)
Layered System
2.Layered
System
Layered System
Advantages of Layered Structure:
• Work duties are separated since each layer has its own functionality, and there
is some amount of abstraction.
• Debugging is simpler because the lower layers are examined first, followed by
the top layers.
Disadvantages of Layered Structure:
• Performance is compromised in layered structures due to layering.
• Construction of the layers requires careful design because upper layers only
make use of lower layers' capabilities.
3. Micro-Kernel System
• Kernel is made as small as possible only the most important services are
put inside the kernel and rest of the OS service are present in the system
application program.
• The user can easily interact with those not-so important services within
the system applications kernel is solely responsible for the three most
important services of operating system namely:
• Inter-Process communication
• Memory management
• CPU scheduling
Micro-Kernel System
• Microkernel and system applications can interact with each other by
message passing as and when required. This is extremely advantageous
architecture since burden of kernel is reduced and less crucial services are
3.Microkern
accessible to the user and hence security is improved too.
•elIt System
is being highly adopted in the present-day systems. MacOSX,Eclipse IDE is
a good example of Microkernel Architecture.
Micro-Kernel System
3.Microkern
el System
Micro Kernel vs Monolithic
S.
Parameters Microkernel Monolithic kernel
No.
In microkernel, user services and In monolithic kernel, both user services
1. Address Space kernel services are kept in separate and kernel services are kept in the same
address space. address space.
Design and OS is easy to design and
2. OS is complex to design.
Implementation implement.
Microkernel are smaller in size. Monolithic kernel is larger than
3. Size
microkernel.
Easier to add new Difficult to add new
4. Functionality
functionalities. functionalities.
To design a microkernel, more Less code when compared to
5. Coding
code is required. microkernel
Micro Kernel vs Monolithic
S. No. Parameters Microkernel Monolithic kernel
Failure of one
Failure of one component does not
component in a
effect the working of micro kernel.
6. Failure monolithic kernel leads to
Monolithi the failure of the entire
system.
c Kernel Execution speed is high.
VS
7. Processing Speed Execution speed is low.
Microkern
8. Extend
It is easy to extend Microkernel. It is not easy to extend
monolithic kernel.
el
To implement IPC messaging queues are used
Signals and Sockets are
by the communication microkernels.
utilized to implement IPC
9. Communication in monolithic kernels.
10. Debugging Debugging is simple. Debugging is difficult.
Micro Kernel vs Monolithic
S. No. Parameters Microkernel Monolithic kernel
Extra time and resources are needed
It is simple to maintain.
Monolithi
11. Maintain for maintenance.
c Kernel Message forwarding and context Message passing and context
VS12. Message passing and
Context switching
switching are required by the
microkernel.
switching are not required while the
kernel is working.
Microkern
el The kernel only offers IPC and
low-level device management
The Kernel contains all of the
operating system’s services.
13. Services services.
Example : Microsoft Windows 95.
14. Example Example : Mac OS X.
4. Modular System
• It is considered as the best approach for an OS. It involves designing of a
modular kernel. The kernel has only a set of core components and other
services are added as dynamically loadable modules to the kernel either
during runtime or boot time.
• It resembles layered structure due to the fact that each kernel has defined
and protected interfaces, but it is more flexible than a layered structure as a
module can call any other module.
Modular System
4. Modular
System
5. Virtual Machine
• 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.
Virtual Machine
• A virtual machine (VM) is an efficient, isolated duplicate of a real machine.
• Enables a single PC or server to simultaneously run multiple operating
systems or multiple sessions of a single OS.
• The individual user was quite conscious of sharing a particular machine with a
number of other users. For example, the user would have to specifically
request certain system resources when they were needed.
• VirtualBox and VMware are examples of virtual machines.
Virtual Machine
5. Virtual
machine
Roles and functions of Kernel
• A kernel is the core component of an operating system.
• Using interprocess communication and system calls, it
acts as a bridge between applications and the data
processing performed at the hardware level.
• When an operating system is loaded into memory, the
kernel loads first and remains in memory until the
operating system is shut down again.
• The kernel is responsible for low-level tasks such as disk
management, task management and memory
management.
Roles and functions of Kernel
• A computer kernel interfaces between the three major computer hardware
components, providing services between the application/user interface and the
CPU, memory and other hardware I/O devices.
• The kernel provides and manages computer resources, allowing other programs
to run and use these resources. The kernel also sets up memory address space
for applications, loads files with application code into memory, sets up the
execution stack for programs and branches out to particular locations inside
programs for execution.
Roles and functions of Kernel
Functions of Kernel
• A Kernel provides access to various computer resources like the CPU, I/O devices.
• It helps in sharing the resources among the various processes so that there are uniform and
equal distribution between all process. It has complete access to system memory and it takes
care of memory allocation for different tasks for their execution. This is done by creating
virtual partitions on the memory based on the requirement of the application.
• All the processes that are performed on the system are through various input/output
devices. The kernel allocates these devices. This is done through the device driver which is
an integral part of the OS and its main function is to allow the OS to interact with the
connected hardware devices.
Roles and functions of Kernel
• It directs the application to the part of memory it (application) can access.
• It provides techniques for communication and synchronization between process
called IPC (Interprocess communication)
• It is very smart in determining and scheduling the time that has to be given to
various processes based on the preferences so that multiple programs can be
executed on the system.
• It also protects from malicious behavior.
UNIX SYSTEM STRUCTURE
UNIX SYSTEM STRUCTURE
Layer-1: Hardware -
This layer of UNIX consists of all hardware-related
information in the UNIX environment.
UNIX SYSTEM
STRUCTURE
Layer-2: Kernel -
• The core of the operating system that's liable for
maintaining the full functionality is named the kernel.
• The kernel of UNIX runs on the particular machine
hardware and interacts with the hardware effectively.
• The kernel is the heart of the operating system.
• The kernel ingests user input via the shell and
accesses the hardware to perform things like memory
allocation and file storage.
UNIX SYSTEM
STRUCTURE
• It also works as a device manager and performs valuable functions for the processes which
require access to the peripheral devices connected to the computer.
• The kernel controls these devices through device drivers.
• The kernel also manages the memory. Processes are executed
programs that have owner's humans or systems who initiate their execution.
• The system must provide all processes with access to an adequate amount of memory, and a
few processes require a lot of it.
• To make effective use of main memory and to allocate a sufficient amount of memory to every
process. It uses essential techniques like paging, swapping, and virtual storage.
UNIX SYSTEM
STRUCTURE
Layer-3: The Shell -
• The Shell is an interpreter that interprets the command submitted by
the user at the terminal, and calls the program you simply want
• Shell are the Soul of the operating system..
• It also keeps a history of the list of the commands you have typed
in.
• If you need to repeat a command you typed it, use the cursor keys
to scroll up and down the list or type history for a list of previous
commands.
• There are various commands like cat, mv, cat, grep, id,wc, and many
more.
UNIX SYSTEM STRUCTURE
Type of Shell:
Bourne Shell: This Shell is simply called the Shell. It was the first
Shell for UNIX OS. It is still the most widely available Shell on
a UNIX system.
C Shell: The C shell is another popular shell commonly available
on a UNIX system. The C shell was developed by the University of
California at Berkeley and removed some of the shortcomings of
the Bourne shell.
Korn Shell: This Shell was created by David Korn to address
the Bourne Shell's user-interaction issues and to deal with the
shortcomings of the C shell's scripting quirks.
UNIX SYSTEM STRUCTURE
Layer-4: Application Programs Layer -
It is the outermost layer that executes the
given external applications. UNIX distributions
typically come with several useful applications
programs as standard.
For Example: emacs editor, StarOffice, xv image
viewer, g++ compiler etc.
UNIX SYSTEM STRUCTURE
• One example of how the shell and kernel work
together is copying a file.
• If you want to copy a file named "file1" and name
the copy "file2", you would enter "cp file1 file2" at
the command line.
• The shell will search for the program "cp" then tell
the kernel to run that program on "file 1"and name
the output "file 2".
• When the copying is finished, the shell returns you
to the prompt and awaits more commands.
Linux vs Unix
Linux Unix
The source code of Linux is freely available The source code of Unix is not freely
to its users available general public
Differenc
It has graphical user interface along with
e between command line interface
It only has command line interface
Unix Linux
and OS is portable, flexible, and can be
Unix OS is not portable
Linux –executed in different hard drives
Different versions of Linux OS are Ubuntu, Linux Mint,
Different version of Unix are AIS, HP-UX, BSD, Iris, etc.
RedHat Enterprise Linux, Solaris, etc.
The file systems supported by Linux are as follows: xfs,
The file systems supported by Unix are as follows: zfs,
ramfs, vfat, cramfsm, ext3, ext4, ext2, ext1, ufs, autofs,
js, hfx, gps, xfs, vxfs
devpts, ntfs
System Call
• A system call is an interface between a program running in user space and the operating system
(OS).
• Application programs use system calls to request services and functionalities from the OS's kernel.
This mechanism allows the program to call for a service, like reading from a file, without accessing
system resources directly.
System
• When a program invokes a system call, the execution context switches from user to kernel mode,
Calls
allowing the system to access hardware and perform the required operations safely. After the
operation is completed, the control returns to user mode, and the program continues its execution.
• System call provides the services of the operating system to the user programs via Application
Program Interface(API).
• System calls are the only entry points into the kernel system. All programs needing
resources must use system calls.
Services Provided by System Calls :
• User-Kernel Boundary. System calls serve as the authorized gateway for user programs when
requesting services from the kernel. They ensure that user programs cannot arbitrarily access
kernel functions or critical system resources.
Services
• Resource Management. User programs can request and manage vital resources like CPU time,
Provided
memory, and file storage via system calls. The OS oversees the process and guarantees that it is
bycompleted in an organized manner.
System
• Streamlined Development. System calls abstract the complexities of hardware. This allows
Calls
developers to perform operations like reading and writing to a file or managing network data
without needing to write hardware-specific code.
Services Provided by System Calls :
• Security and Access Control. System calls implement checks to ensure that requests
made by user programs are valid and that the programs have the necessary permissions
to perform the requested operations.
• Inter-Process Communication (IPC). System calls provide the mechanisms for
processes to communicate with each other. They offer features like pipes, message
queues, and shared memory to facilitate this inter-process communication.
• Network Operations. System calls provide the framework for network communications
between programs. Developers can devote their attention to building their application's
logic instead of focusing on low-level network programming.
Working of System Calls :
Services
Provided
by
System
Calls
Working of System Calls :
1. System Call Request. The application requests a system call by invoking its corresponding function. For
instance, the program might use the read() function to read data from a file.
2. Context Switch to Kernel Space. A software interrupt or special instruction is used to trigger a context
switch and transition from the user mode to the kernel mode.
Services
3. System Call Identified. The system uses an index to identify the system call and address the
Provided
corresponding kernel function.
by
4. Kernel Function Executed. The kernel function corresponding to the system call is executed. For
System
example, reading data from a file.
5. System Prepares Return Values. After the kernel function completes its operation, any return values or
Calls
results are prepared for the user application.
6. Context Switch to User Space. The execution context is switched back from kernel mode to user mode.
7. Resume Application. The application resumes its execution from where it left off, now with the results or
effects of the system call.
Types of System Calls :
Types of System Calls :
File Management System Calls:
• 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. Wheneve 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.
Types of System Calls :
Process Control System Calls:
• 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.
Types of System Calls :
• 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 processes are forked.
• exit(): It simply terminates the current process.
• kill(): This call sends a signal to a specific process and has various purpose including –
requesting it to quit voluntarily, or force quit, or reload configuration.
Types of System Calls :
fork() vs exec():
Features Fork() Exec()
Definition It is a command that allows a process to It is a command that makes a new process
copy itself. by replacing the existing process.
Address Space The parent and child processes are in The child address space replaces the parent
separate address spaces in the fork(). address space in the exec().
Parent Process There is a child process and a parent There is only a child process after calling
process after calling the fork() function. the exec().
Result The fork() makes a child's process equal The exec() makes a child process and
to the parent's process. replaces it with the parent process.
Types of System Calls :
Memory Management System Calls:
• brk(): Changes the data segment size for a process in HEAP Memory. It takes an address as argument to
define the end of the heap and explicitly sets the size of HEAP.
• sbrk(): This call is also for memory management in heap, it also takes an argument as an integer (+ve or
-ve) specifying whether to increase or decrease the size respectively.
• mmap(): Memory Map – it basically maps a file or device into main memory and further into a
process’s address space for performing operations. And any changes made in the content of a file will be
reflected in the actual file.
• munmap(): Unmaps a memory-mapped file from a process’s address space and out of main memory
• mlock() and unlock(): memory lock defines a mechanism through which certain pages stay in memory
and are not swapped out to the swap space in the disk. This could be done to avoid page faults. Memory
unlock is the opposite of lock, it releases the lock previously acquired on pages.
Types of System Calls :
Inter Process Communication (IPC) System Calls:
• pipe(): Creates a unidirectional communication channel between processes. For
example, a parent process may communicate to its child process through a pipe making
a parent process as input source of its child process.
• socket(): Creates a network socket for communication. Processes in same or other
networks can communicate through this socket, provided that they have necessary
network permissions granted.
• shmget(): It is short for – ‘shared-memory-get’. It allows one or more processes to share
a portion of memory and achieve interprocess communication.
Types of System Calls :
• semget(): It is short for – ‘semaphore-get’. This call typically manages the
coordination of multiple processes while accessing a shared resource that is, the
critical section.
• msgget(): It is short for – ‘message-get’. IPC mechanism has one of the fundamental
concept called – ‘message queue’ which is a queue data structure inside memory
through which various processes communicate with each other. This message queue is
allocated through this call allowing other processes a structured way of
communication for data exchange purpose.
Types of System Calls :
Device Management System Calls:
• 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.
System Calls: Interrupts
An interrupt is a signal to the processor emitted by
hardware or software indicating an event that needs
immediate attention
The processor responds by suspending its current activities,
saving its state, and executing a function needed by interrupt
This interruption is temporary, and, after the interrupt handler
finishes,
the processor resumes normal activities.
There are two types of interrupts: hardware interrupts and
software interrupts.
System Calls: Interrupts
Hardware interrupt Software interrupt
pressing a key on the errors or events occurring
keyboard or moving the during program execution that
mouse triggers hardware are cannot be handled within
interrupts that cause the the program itself.
processor to read the keystroke
or mouse position.
For example, if the processor's
arithmetic logic unit is
commanded to divide a number
by zero.
Hardware vs Software Interrupt
SR.NO. Hardware Interrupt Software Interrupt
Software interrupt is the interrupt that is
Hardware interrupt is an interrupt generated from an
1 generated by any internal system of the computer.
external device or hardware.
2 It do not increment the program counter. It increment the program counter.
Hardware interrupt can be invoked with some external
Software interrupt can be invoked with the help of
3 device such as request to start an I/O or occurrence of
INT instruction.
a hardware failure.
4 It has lowest priority than software interrupts It has highest priority among all interrupts.
Hardware interrupt is triggered by external hardware Software interrupt is triggered by software and
and is considered one of the ways to communicate with considered one of the ways to communicate with kernel
5
the outside peripherals, hardware. or to trigger system calls, especially during error or
exception handling.
6 It is an asynchronous event. It is synchronous event.
Hardware interrupts can be classified into two types Software interrupts can be classified into two types
7 they are: 1. Maskable Interrupt. 2. Non Maskable they are: 1. Normal Interrupts. 2.
Interrupt. Exception
Keystroke depressions and mouse movements are All system calls are examples of software
8
examples of hardware interrupt. interrupts
Thank You