Fundamental Concepts
Sakshi Education
Introduction
Understanding Operating System: Generally the Operating System is defined as central software which manages and allocates the computer resources like CPU, RAM, Memory and other peripheral devices. From the programmers point of view the Operating System is simply integration of two pieces of code that is integration of “shell and kernel”.
Any kernel has three important core components.
The execution of architecture specific code and In-kernel is referred to as system boot and user can interact with the system only after boot process is completed. The modern processor architectures typically allow the CPU to operate in two type’s modes and they are user mode and kernel mode. Hardware instructions allow switching from one mode to other mode.
User mode: In user mode the CPU can access only memory that is marked in user space.
Kernel mode: In kernel mode the CPU can access both user space and kernel space memory.
Some operations are performed only when the processor is running in the kernel mode, like executing the halt instruction to stop the system, initiating device I/O operations and etc. By taking advantage of hardware design to place operating system in kernel space can ensure that user processes are not able to access the data structures and instructions in the kernel space.
Types of kernels
Tasks performed by kernel
The following are the some tasks performed by the kernel.
The Shell
A command line interpreter is a computer program that reads singular lines of text entered by the user and interprets them in the context of given operating system. A shell is a special purpose program designed to read commands typed by user and execute the appropriate programs in response to those commands. This interaction takes place by means command line interface and it is indicated by console or shell. Commands are input in a terminal and the results are displayed on the terminal console. The shells are designed not only for interactive use but also for the interpretation of shell scripts, which are text files containing shell commands and it can execute multiple commands simultaneously. There are different types of shells available for UNIX systems and some of them are following.
A C shell compatible implementation with evolved features.
Virtualization
Virtualization is the concept of sharing a single hardware platform among multiple operating systems. The hypervisor is a piece of code or kernel which is used to manage all the hardware resources for various operating system domains called guest domains. Hypervisors is same as kernel and use virtual drivers to emulate the physical hardware for guest operating system.
Hypervisor
The Hypervisor job is to allocate time for the operating systems to run on the platform and to manage the interactions between each operating system and the hardware platform. Each of these operating system environments sees its own virtual machine.
There are two types of hypervisors.
Advantages:
Understanding Operating System: Generally the Operating System is defined as central software which manages and allocates the computer resources like CPU, RAM, Memory and other peripheral devices. From the programmers point of view the Operating System is simply integration of two pieces of code that is integration of “shell and kernel”.
- Shell – provides user interaction to interact with kernel and it is responsible for all user interactions.
- Kernel – Kernel is the core of the operating system and the performance of the operating system depends on the kernel. A kernel takes the user request and processes the request and make sure that application launches. The kernel is about core services of the operating system, the core services include hardware management, user request processing and application services.
Figure1: Block Diagram Operating System kernel
Any kernel has three important core components.
- Architecture Specific: Take care of hardware and on board controllers. This is responsible for initializing the processor on the hardware and various device controllers connected to processor.
- In-kernel: Initialize all the data structures required for the functioning of the kernel. For example: memory tables and interrupt tables.
- Loader: This is responsible for loading user applications and launching them.
The execution of architecture specific code and In-kernel is referred to as system boot and user can interact with the system only after boot process is completed. The modern processor architectures typically allow the CPU to operate in two type’s modes and they are user mode and kernel mode. Hardware instructions allow switching from one mode to other mode.
User mode: In user mode the CPU can access only memory that is marked in user space.
Kernel mode: In kernel mode the CPU can access both user space and kernel space memory.
Some operations are performed only when the processor is running in the kernel mode, like executing the halt instruction to stop the system, initiating device I/O operations and etc. By taking advantage of hardware design to place operating system in kernel space can ensure that user processes are not able to access the data structures and instructions in the kernel space.
Types of kernels
- Monolithic kernels
Monolithic kernels are statically build kernel images by integrating core modules and services and the entire operating system is placed in kernel space. Monolithic kernels are loaded to kernel space/supervisor mode (ring 0). The applications are loaded to user space or ring3.
Examples: Windows and UNIX
- Micro kernels
The kernel image is built using core component and deployed into kernel space/supervisor mode (ring 0). In this bare minimum of code runs in kernel space and rest of Kernel services are built as the loadable components and deployed on demand to ring1/ring2 (middle ware space). Applications are always deployed in user space or ring3.
- The kernels can be designed and deployed on a general purpose platform or an embedded platform or a real time platform.
- Kernels designed for general purpose platforms contains different types of services and are often higher in memory.
- Kernels designed for embedded platforms have limited services and are often smaller in size.
- Real time kernels provide fully deterministic and deadline oriented services. They can exist on a general purpose computing platform or embedded platform.
Figure2: Difference between monolithic kernel and micro kernel
Tasks performed by kernel
The following are the some tasks performed by the kernel.
- Creation and termination of process: The kernel can load a new program into memory and providing it with the resources like CPU and memory. The instance of a running a program is called a process. Once the process has completed its execution the kernel ensures that the resources it uses are freed and given to other processes in the queue.
- Process scheduling: The computer has one or more CPUs, which will execute instructions. The Linux operating system is multitasking operating system, multitasking means that multiple processes can run simultaneously reside in memory and each may receive use of the CPUs.
- Memory management: The physical RAM is a limited resource that the kernel must share among the processes in an equal and efficient manner, like most of the latest operating systems employs virtual memory management technique with that have two main advantages:
- Processes are isolated from one another and from the kernel, so that one process can’t read or modify the memory of other process or the kernel.
- Only part of a process needs to be kept in memory, thereby lowering the memory requirements of each process and allowing more processes to be held in RAM simultaneously.
- Networking: the kernel transmits and receives network messages on behalf of user processes.
- Access to external devices: The devices attached to computer allows to communication of information between computer and external world.
- Provision of a system call application programming interface: processes can be request the kernel to perform various tasks using systems calls.
The Shell
A command line interpreter is a computer program that reads singular lines of text entered by the user and interprets them in the context of given operating system. A shell is a special purpose program designed to read commands typed by user and execute the appropriate programs in response to those commands. This interaction takes place by means command line interface and it is indicated by console or shell. Commands are input in a terminal and the results are displayed on the terminal console. The shells are designed not only for interactive use but also for the interpretation of shell scripts, which are text files containing shell commands and it can execute multiple commands simultaneously. There are different types of shells available for UNIX systems and some of them are following.
- sh: The Bourne shell
The Basic shell found on every UNIX systems. This is the oldest shell used in many operating systems and was written by Steve Bourne. The Bourne shell contains many of features familiar in all shells.
- csh: The C shell
This shell was written by Bill Joy at the University of California. It is popular with C –like syntax. The C shell provided several useful interactive features unavailable in the Bourne shell.
- ksh: Korn shell
The Korn shell was written as the successor to the Bourne shell by david Korn at AT&T Bell Laboratories.
- bash: The Bourne again shell
This shell is the GNU project reimplementation of the Bourne shell. This provides interactive features similar to those available in the C and Korn shell. It is a sh shell with improved features.
- tcsh: The TC shell
A C shell compatible implementation with evolved features.
Virtualization
Virtualization is the concept of sharing a single hardware platform among multiple operating systems. The hypervisor is a piece of code or kernel which is used to manage all the hardware resources for various operating system domains called guest domains. Hypervisors is same as kernel and use virtual drivers to emulate the physical hardware for guest operating system.
Figure3: Block diagram of Virtualization
Hypervisor
The Hypervisor job is to allocate time for the operating systems to run on the platform and to manage the interactions between each operating system and the hardware platform. Each of these operating system environments sees its own virtual machine.
There are two types of hypervisors.
- Type 1 hypervisor is also called Bare Metal Hypervisor: Type 1 hypervisors are considered as bare metal hypervisor and runs directly on top of the hardware. The type1 hypervisor is often referred as hardware virtualization hypervisor. This type of hypervisors can be implemented using architecture emulation approach and native virtualization approach. Native virtualization provides good performance over architecture emulation.
a. Emulation approach involves hypervisor emulating different hardware architectures for virtual machines to be configured. For example allowing a virtual machine with power pc architecture to be configured on Intel X86 architecture.
b. Native virtualization involves emulation of host architecture while configuring virtual machines.
Examples: Xen, VMware ESX Server
- Type 2 hypervisor: The Type 2 hypervisor operates as an application on top of an existing operating system.
Examples: KVM, VMware Workstation
The Type1 hypervisor provides better performance and greater flexibility because it operates as a thin layer designed to expose hardware resources to virtual machines, and reducing overheads required to run the hypervisor itself, because the Type1 hypervisor runs directly on hardware where as Type2 hypervisor runs on top of operating system as an application.
Figure4: Types of Hypervisors
Advantages:
- The general purpose operating systems can be used alongside RTOS in embedded operating systems.
- Security for critical software
- For applications developers to assist developing, testing, debugging and portable applications.
Published date : 04 Nov 2015 11:03AM