Please disable adblock to view this page.

← Go home

Operating System, Kernal and its types

operating-system-model

October 30, 2016
Published By : Pratik Kataria
Categorised in:

What is operating system?

Computer = set of resources
–Processor(s), memory, I/O & communication devices
OS
–Enables use of resources
–Manages resources
–The low-level software that supports a computer’s basic functions, such as scheduling tasks and controlling peripherals
Resources not limited to hardware
Shift from
–Pure efficient use of resources to
–Enhance user experience

Operating System Model

operating-system-model

As you can see in the above diagram the application runs on top of the OS. Only the OS has full access to the underlying hardware.

What is the kernel?

A kernel is a central component of an operating system.
It acts as an interface between the user applications and the hardware.
The aim of the kernel is to manage the communication between the software (user level applications) and the hardware (CPU, disk memory etc)

Part of UNIX OS that contains code for:

  • Controlling execution of process 
  • Scheduling process fairly 
  • Allocating main memory 
  • Allocating secondary memory 
  • Handling peripherals

Characteristics of kernel

Loading and existence into main memory

Mostly written in C and assembly language

Use programs accesses kernel services via system call interface

Provides its services transparently

Terminology

Kernel mode or kernel space

User mode or user space

Operating system components

Processor scheduler

Memory manager

I/O manager

Inter-process communication manager

File system manager

Processor scheduler:

A process is a program in execution.
A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task. „
The operating system is responsible for the following activities in connection with process management. – Process creation and deletion. – process suspension and resumption.

Memory manager:

Memory is a large array of words or bytes, each with its own address
Main memory is a volatile storage device and it loses its contents in the case of system failure
The operating system is responsible for the following activities in connections with memory management:
–Keep track of which parts of memory are currently being used and by whom.
–Decide which processes to load when memory space becomes available.
–Allocate and deallocate memory space as needed.

I/O manager:

The I/O system consists of: – A buffer-caching system – A general device-driver interface – Drivers for specific hardware devices

Inter-process communication manager:

Interprocess communication (IPC) is a set of programming interfaces that allow a programmer to coordinate activities among different program processes that can run concurrently in an operating system.
This allows a program to handle many user requests at the same time.

File system manager:

The operating system is responsible for the following activities in connections with file management: –
File creation and deletion. – Directory creation and deletion. – Support of primitives for manipulating files and directories. –
Mapping files onto secondary storage. – File backup on stable (nonvolatile) storage media.

Operating system architectures

OS tends to be complex because:

  • Provides many services
  • Support variety of hardware and software

Types:

  • Monolithic
  • Layered
  • Micro
  • Exo

Monolithic Kernel

All OS functionality is included in single address space
Strong points – well understood, good performance
Problems:

  • Kernel components aren’t protected from each other
  • Not easily extended / modified
  • May be unclear structure

Eg – UNIX, Linux, most commercial system

monolithic-kernel

Microkernel

microkernel

Provides set of minimal core services
Interface to hardware layer
Max functionality is moved to user space
Essential functions in kernel:

  • Primitive memory management
  • I/O & interrupt management
  • Inter-process communication
  • Basic scheduling

Message passing is a communication mean
Eg – Win NT, Chorus etc.

BENEFITS

Extensibility / reliability
Easier to extend
More reliable
More secure
Rigorously tested
Easy to maintain
Easy to add/change services
Better security
Distributed services over the network

microkernel1

Exokernel

Exokernel is an operating system kernel developed by the MIT Parallel and Distributed Operating Systems group, and also a class of similar operating systems.
Operating System Kernels generally present the hardware-resources to applications through high level abstractions such as the (virtual) file-system.
Goal of exokernel: to give applications more control
Main functionality is protection and multiplexing of the raw hardware
A major advantage of exokernel based systems is that they can incorporate multiple library operating systems, so Linux and Windows can work simultaneously

Separates resource allocation & protection from resource management

  • To provide extensibility to applications, allowing them to exploit performance
  • Also, to provide a base for a general purpose (well rounded) system

Traditional UNIX Kernel

traditional-unix-kernel

Three levels: a. user level, b. kernel level, c. hardware level
File subsystem: manages file, allocating file space, retrieving data for users etc.
Hardware control: responsible for handling interrupts and for communicating with the machine.
File subsystem and process control subsystem interact when loading a file into memory for execution.
The memory management module controls allocation of memory.
Scheduler module allocates CPU to the processes.

General UNIX architecture

general-unix-architecture

Operating System Booting

Booting is a bootstrapping process that starts OS when the user turns on computer system
Boot sequence is set of operations the computer performs when it is switched on that load an operating system
During bootstrapping, the kernel is loaded into memory and begins to execute.
A variety of initialization tasks are performed and then the system is made available to users

The primitive loader program that can load and execute the boot program is called Bootstrap program, and it is typically stored in ROM.
On start up, computer automatically reads the bootstrap program.
The boot program is generally stored on disk with predetermined address, called boot sector.
The boot program then loads the operating system into memory, this is called bootstrapping.

How UNIX boots?

unix-boot-process

When the computer is switched on, it’s of no use because the data stored in the memory (RAM) is garbage and there is no Operating System running.

The first thing motherboard does is to initialize its own firmware and get the CPU running.

Functions of Basic Input/Output System (BIOS)

POST (Power On Self Test) to ensure that the various components present in the system are functioning properly.

If video card is missing or not functioning properly motherboard emit beeps since error cannot be displayed.

It initializes the various hardware devices and it is an important process so as to ensure that all the devices operate smoothly without any conflicts.

Generally the operating system is present in the hard disk. We will confine our discussion to how operating system boots from the hard disk.

Master Boot Record

The first sector of the hard disk is called Master Boot Record (MBR).
The structure of MBR is operating system independent. It is of 512 bytes and it has mainly two components.
The first 446 bytes contain a special program called Bootstrap Loader.
The next 64 bytes contains a partition table.
A partition table stores all the information about the partitions in a hard disk and file system types (a file system describes how data will be stored and retrieved from the partition).

master-boot-record

A partition table is required to boot up the operating system.

The last two bytes of MBR contains a magic number AA55.

It is used to classify whether the MBR is valid or not.

An invalid magic number indicates that the MBR is corrupt and machine will not be able to boot.

Bootstrap Loader

Bootstrap loader or the boot loader contains the code to load an operating system.
Earlier Linux distributions used LILO (LInux Loader) bootloader.
Today, most of the distributions use GRUB (GRand Unified Bootloader) which has many advantages over LILO.
BIOS loads the bootstrap loader into the memory (RAM) and starts executing the code.
Booting an operating system with GRUB is a two stage process: stage 1 and stage 2
Stage 1 is the boot loader code itself and its task is to only call the stage 2 which contains the main code

Kernel

Kernel is the core component of an operating system.
It has complete control of all the things happening in a system.
It is the first part of the operating system to load into the memory and remains there throughout the session.

INIT

This is the main and last stage of Booting Process
init(initialization) process is the root/parent process of all the process which run under Linux/Unix.
The first process it runs is a script which check all the system properties, hardware, display, load kernel modules, file system check, file system mounting etc.
Based on the appropriate run-level, scripts are executed to start/stop various processes to run the system and make it functional.
INIT will start each run level one after the other and start executing scripts corresponds to that run level.

Pratik Kataria is a budding programmer, web designer and developer.