Kernel appropriate kernel service routine to handle the

Kernel mode and User mode of CPU operationThe CPU can execute certain instruction only when it is in the kernel mode. These instruction are called privilege instruction. They allow implementation of special operation whose execution by the user program could interface with the functioning of operating system or activity of other user program. For example, instruction for managing memory protection.The operating system puts the CPU in kernel mode when it is executing in the kernel so, that lernel can execute special operation.The operating system puts the CPU in user mode when a user program is in execution so, that user program cannot interface with the operating system program.User-level instruction does not require special privilege. Example are ADD,PUSH,etc.The concept of modes can be extended beyond two, requiring more than a single mode bit CPUs that support virtualization use one of these extra bits to indicate when the virtual machine manager, VMM, is in control of the system. The VMM has more privileges than ordinary user programs, but not so many as the full kernel.System calls are typically implemented in the form of software interrupts, which causes the hardware’s interrupt handler to transfer control over to an appropriate interrupt handler, which is part of the operating system, switching the mode bit to kernel mode in the process. The interrupt handler checks exactly which interrupt was generated, checks additional parameters ( generally passed through registers ) if appropriate, and then calls the appropriate kernel service routine to handle the service requested by the system call.User programs’ attempts to execute illegal instructions ( privileged or non-existent instructions ), or to access forbidden memory areas, also generate software interrupts, which are trapped by the interrupt handler and control is transferred to the OS, which issues an appropriate error message, possibly dumps data to a log ( core ) file for later analysis, and then terminates the offending program.Kernel-Wide Design ApproachMonolithic kernel: All operating system services run along with the main kernel thread also residing in the same memory area. This approach provides rich and powerful hardware access. Example: Laptop,etc.Micro kernel: It uses message passing system of some sort to handle request from one server to another server.Hybrid or Modular Kernel: Commercial operating system additional code in kernel space to increase the performance. Example: Railway reservation system, etc.Nano kernel:It contains all services, interrupt controller pr the timer to device drivers. Example: Timer is not set.Exo kernel: It is still being experimented for the operating system design. Example: For experimental purpose and research work, etc.Kernel Data StructuresIt is similar to standard programming data structures. Following are some of them:1)Linked List: A linked list is a linear collection of data elements, called nodes, each pointing to the next node by means of a pointer.2)Doubly linked list:In a ‘doubly linked list’, each node contains, besides the next-node link, a second link field pointing to the ‘previous’ node in the sequence. The two links may be called ‘forward(‘s’) and ‘backwards’, or ‘next’ and ‘prev'(‘previous’).3)Circular Linked List:In the last node of a list, the link field often contains a null reference, a special value used to indicate the lack of further nodes. A less common convention is to make it point to the first node of the list; in that case the list is said to be ‘circular’ or ‘circularly linked’; otherwise it is said to be ‘open’ or ‘linear’.4)Binary Search tree:They also known as ordered or sorted binary trees. They are data structures that store “items” (such as numbers, names etc.) in memory. They allow fast lookup, addition and removal of items. In binary search tree for looking a key in a tree, they traverse from the root node to the leaf node searching in the left or right subtrees by making comparisons to key stored in nodes of tree.Search performance is O(n)Complexity of Balanced binary search tree is O(lg n)5)Hash Functions and maps: Hash function can create a hash map6)Bitmaps:A string of 1s and 0s used to keep track of the boolean state of a collection of objects, such as the free state of blocks on a disk or pages in memory.