0% found this document useful (0 votes)
17 views21 pages

Understanding Operating System Kernels

Uploaded by

gdcumerzai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views21 pages

Understanding Operating System Kernels

Uploaded by

gdcumerzai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Kernel

System Programming
7th Semester, Fall 2022

Sys tem Programming

What is Kernel

• In computer science,
• Kernel is a computer program that is a core
or heart of an operating system.
• Before discussing kernel in detail, let's first
understand its basic, i.e., Operating system in
a computer

System Programming 2
Operating System
• An operating system or OS is system software
that works as an interface between hardware
components and end-user.
• It enables other programs to run.
• Each computer system, whether it is desktop,
laptop, tablet, or smartphone, all must have
an OS to provide basic functionalities for the
device.

System Programming 3

What is Kernel (Operating System)?

• As discussed above, Kernel is the core part of


an OS(Operating system); hence it has full
control over everything in the system.
• Each operation of hardware and software is
managed and administrated by the kernel.
• It acts as a bridge between applications and
data processing done at the hardware level.
• It is the central component of an OS.

System Programming 4
What is Kernel (Operating System)?
• It is the part of the OS that always resides in
computer memory and enables the
communication between software and
hardware components.
• It is the computer program that first loaded
on start-up the system (After the bootloader).
• Once it is loaded, it manages the remaining
start-ups. It also manages memory,
peripheral, and I/O requests from software.

System Programming 5

What is Kernel (Operating System)?

• Moreover, it translates all I/O requests into


data processing instructions for the CPU.
• It manages other tasks also such as memory
management, task management, and disk
management.
• A kernel is kept and usually loaded into
separate memory space, known as protected
Kernel space.

System Programming 6
What is Kernel (Operating System)?
• It is protected from being accessed by
application programs or less important parts
of OS.
• Other application programs such as browser,
word processor, audio & video player use
separate memory space known as user-
space.
• Due to these two separate spaces, user data
and kernel data don't interfere with each
other and do not cause any instability and
slowness.
System Programming 7

What is Kernel (Operating System)?

• The operating system provides us a graphic


interface to give the command to the
computer system.
• But system can’t understand these
commands directly.
• Translation of code into binary language done
by the core component of an operating
system (OS), i.e., KERNEL.
• User deal with the lowest layer of kernel and
then kernel deal with system.
System Programming 8
What is Kernel (Operating System)?

• Kernel plays a role of mediator between


system hardware and software.
• The kernel is not an operating system (OS); it
is a central module of operating system.
• It is the first program that is loaded into
protected memory area during the booting
process.
• It remains present in memory till the system
power is on.
System Programming 9

What is Kernel (Operating System)?

• The kernel is a low-level abstraction layer.


• User’s operation used a system call to interact
with system.
• System calls invoke kernel, and then kernel
executes user’s operation.
• Kernel use space to manage all the working of
a system like process management, memory
management, device management, I/O
management and the user using user-space
for running program or writing a program.
System Programming 10
Functions of a Kernel
• A kernel of an OS is responsible for
performing various functions and has control
over the system.
• Some main responsibilities of Kernel are
given below:
• Device Management
• Memory Management
• Resource Management
• Accessing Computer Resources
System Programming 11

Functions of a Kernel
(Device Management)
• To perform various actions, processes require
access to peripheral devices such as a mouse,
keyboard, etc., that are connected to the
computer.
• A kernel is responsible for controlling these
devices using device drivers.
• Here, a device driver is a computer program that
helps or enables the OS to communicate with
any hardware device.
• A kernel maintains a list of all the available
devices, and this list may be already known,
configured by the user, or detected by OS at
runtime.
System Programming 12
Functions of a Kernel
(Memory Management)
• The kernel has full control for accessing the
computer's memory.
• Each process requires some memory to work,
and the kernel enables the processes to safely
access the memory.
• To allocate the memory, the first step is known
as virtual addressing, which is done by paging or
segmentation.
• Virtual addressing is a process of providing
virtual address spaces to the processes. This
prevents the application from crashing into each
other.
System Programming 13

Functions of a Kernel
(Resource Management)
• One of the important functionalities of Kernel
is to share the resources between various
processes.
• It must share the resources in a way that each
process uniformly accesses the resource.
• The kernel also provides a way for
synchronization and inter-process
communication (IPC). It is responsible for
context switching between processes.

System Programming 14
Functions of a Kernel
(Accessing Computer Resources)
• A kernel is responsible for accessing computer
resources such as RAM and I/O devices.
• RAM or Random-Access Memory is used to
contain both data and instructions.
• Each program needs to access the memory to
execute and mostly wants more memory than
the available.
• For such a case, Kernel plays its role and decides
which memory each process will use and what to
do if the required memory is not available.
• The kernel also allocates the request from
applications to use I/O devices such as
keyboards, microphones, printers, etc.
System Programming 15

Types of Kernel
• Kernels are defined according to their design
and functionality.

• Monolithic Kernel
• Micro kernel
• Hybrid Kernel

System Programming 16
Types of Kernel - Monolithic Kernel
• In a monolithic kernel, the same memory
space is used to implement user services and
kernel services.
• It means, in this type of kernel, there is no
different memory used for user services and
kernel services. As it uses the same memory
space, the size of the kernel increases,
increasing the overall size of the OS.
• The execution of processes is also faster than
other kernel types as it does not use separate
user and kernel space
System Programming 17

Types of Kernel
Monolithic Kernel
• A monolithic kernel is a single code program
with the ability to load OS services in single
address space of memory (Kernel Space).
• All OS services run in privileged mode.
• All services like memory management
process management, I/O drivers, and
memory driver’s lies in kernel space reduce
access time give higher performance.
System Programming 18
Types of Kernel
Monolithic Kernel
• Monolithic kernel code is more significant
than micro kernel code.
• Due to large size, it is difficult to maintain the
kernel.
• If services occur in kernel code, the entire
system will stop to work. A monolithic kernel
is not portable, so different platform required
different kernel.
System Programming 19

Types of Kernel - Monolithic Kernel


• Examples of Monolithic Kernels are Unix, Linux,
Open VMS, XTS-400, etc.

• Advantages:
• The execution of processes is also faster as there
is no separate user space and kernel space and
less software involved.
• As it is a single piece of software hence, it's both
sources and compiled forms are smaller.

System Programming 20
Types of Kernel - Monolithic Kernel
• Disadvantages:
• If any service generates any error, it may
crash down the whole system.
• These kernels are not portable, which means
for each new architecture, they must be
rewritten.
• Large in size and hence become difficult to
manage.
• To add a new service, the complete operating
system needs to be modified.
System Programming 21

Types of Kernel (Micro kernel)


• A microkernel is also referred to as μK, and it is
different from a traditional kernel or
Monolithic Kernel.
• In this, user services and kernel services are
implemented into two different address
spaces: user space and kernel space.
• Since it uses different spaces for both the
services, so, the size of the microkernel is
decreased, and which also reduces the size of
the OS.
System Programming 22
Types of Kernel (Micro kernel)
• Microkernels are easier to manage and
maintain as compared to monolithic kernels.
• Still, if there will be a greater number of
system calls and context switching, then it
might reduce the performance of the system
by making it slow.
• These kernels use a message passing system
for handling the request from one server to
another server.

System Programming 23

Types of Kernel (Micro kernel)


• Only some essential services are provided by
microkernels, such as defining memory
address spaces, IPC (Interprocess
Communication), and process management.
• Other services such as networking are not
provided by Kernel and handled by a user-
space program known as servers.

System Programming 24
Types of Kernel (Micro kernel)
• One of the main disadvantages of monolithic
kernels that an error in the kernel can crash
the whole system, can be removed in the
microkernel.
• As in a microkernel, if a kernel process
crashes, the crashing of the whole system can
still be prevented by restarting the error-
caused services.

System Programming 25

Types of Kernel
Micro kernel
• Micro kernel used both kernel and user space
to run all the system processes.
• Kernel divided into various processes known
as services.
• Minimum of services like IPC (Inter-Process
Communication), basic scheduler, or
scheduling primitives, basic memory
handling, primary I/O primitives are in kernel
space.
System Programming 26
Types of Kernel
Micro kernel
• All services like Scheduler, memory handling,
file systems, and network stacks are
separately running in user space.
• It reduces the size of kernel
• Micro kernel used system calls to implement
thread management, inter-process
communication, and memory management.
• Processes which are handled by the kernel in
user space are known as servers.
System Programming 27

Types of Kernel
Micro kernel
• Message passing system is used to control
server request. A large number of system
calls takes lots of time for context switching
which makes the kernel slow as a comparison
to Monolithic Kernel.
• QNX and the HURD used a micro kernel.
• Micro kernels are best for small process
system. So less complication in process
management.
System Programming 28
Types of Kernel
Micro kernel
• Monolithic kernels designed for kernel space
or Micro kernel is intended for user and
kernel space.
• Monolithic model performance is more
efficient than micro kernel.
• The monolithic kernel used share kernel
memory concept but the message is passing
in IPC system of micro kernel design makes it
less useful.
System Programming 29

Types of Kernel (Micro kernel)


• Examples of Microkernel are L4, AmigaOS,
Minix, K42, etc.
• Advantages
• Microkernels can be managed easily.
• A new service can be easily added without
modifying the whole OS.
• In a microkernel, if a kernel process crashes, it
is still possible to prevent the whole system
from crashing.
System Programming 30
Types of Kernel (Micro kernel)
• Disadvantages
• There is more requirement of software for
interfacing, which reduces the system
performance.
• Process management is very complicated.
• The messaging bugs are difficult to fix.

System Programming 31

Types of Kernel (Hybrid Kernel)


• Hybrid kernels are also known as modular
kernels, and it is the combination of both
Monolithic and Microkernels.
• It takes advantage of the speed of monolithic
kernels and the modularity of microkernels.
• A hybrid kernel can be understood as the
extended version of a microkernel with
additional properties of a monolithic kernel.

System Programming 32
Types of Kernel (Hybrid Kernel)
• These kernels are widely used in commercial
OS, such as different versions of MS Windows.
• It is much similar to a microkernel, but it also
includes some additional code in kernel space
to enhance the performance of the system.
• Hybrid kernels allow to run some services such
as network stack in kernel space to reduce the
performance compared to a traditional
microkernel, but it still allows to run kernel
code (such as device drivers) as servers in user-
space. System Programming 33

Types of Kernel
Hybrid Kernel
• A hybrid kernel is extending version of a
micro-kernel with adding some functionality
of Monolithic kernel.
• A hybrid kernel divided into services same as
a micro-kernel, and they all executed in same
kernel space as the Monolithic kernel.
• NT kernels for windows and XNU kernel used
by Apple for mac OS
System Programming 34
Types of Kernel
Hybrid Kernel
• Kernel mode contains Application PC, device
drivers and virtual memory, scheduling
process.
• It reduces the overhead of message passing
and context switching time.
• File server and UNIX server are in user mode.
The file server is memory area where the
application gets executed.
System Programming 35

Difference between Operating


System and Kernel
• OS is system software package and kernel is a
part of OS who manage all processes and
devices.
• The operating system is an interface between
user and hardware.
• The kernel is an interface between software
and hardware.
• Kernel helps the program to communicate
with peripheral devices
System Programming 36
Types of Kernel (Hybrid Kernel)
• Examples of Hybrid Kernel are Windows NT,
Netware, BeOS, etc.
• Advantages:
• There is no requirement for a reboot for
testing.
• Third-party technology can be integrated
rapidly.

System Programming 37

Types of Kernel (Hybrid Kernel)


• Disadvantages:
• There is a possibility of more bugs with more
interfaces to pass through.
• It can be a confusing task to maintain the
modules for some administrators, especially
when dealing with issues such as symbol
differences.

System Programming 38
Types of Kernel (Nanokernel)
• As the name suggests, in Nanokernel, the
complete code of the kernel is very small,
which means the code executing in the
privileged mode of the hardware is very
small. Here the term nano defines a kernel
that supports a nanosecond clock resolution.

• Examples of Nanokernel are EROS etc.

System Programming 39

Types of Kernel (Exokernel)


• Exokernel is still developing and is the
experimental approach for designing OS.
• This type of kernel is different from other
kernels as in this; resource protection is kept
separated from management, which allows
us to perform application-specific
customization.

System Programming 40
Types of Kernel (Exokernel)
• Advantages:
• The exokernel-based system can incorporate
multiple library operating systems. Each
library exports a different API, such as one
can be used for high-level UI development,
and the other can be used for real-time
control.
• Disadvantages:
• The design of the exokernel is very complex.
System Programming 41

What is Kernel Panics?


• As we have already discussed, that kernel
controls over entire computer system; hence if it
crashes, it can take down the whole system. In
MacOS and Linux, such an undesirable event is
known as "Kernel Panic." To recover from kernel
Panic, we need to restart the system.
• Usually, these kernel panics are caused by
hardware communication issues. Hence, if
repeated kernel panics are occurring, then try to
unplug the less required or unnecessary devices
and check if the problem is get resolved or not.
System Programming 42

You might also like