UNIT II Introduction to the Kernel 1 Kernel

  • Slides: 21
Download presentation
UNIT -II Introduction to the Kernel

UNIT -II Introduction to the Kernel

1. Kernel: • • • kernel is the central component of operating system. It

1. Kernel: • • • kernel is the central component of operating system. It acts as an interface between the user applications and the hardware. kernel is a computer program that manages input/output requests from software and translates them into data processing instructions for the CPU and other electronic components of a computer. kernel can provide the lowest-level abstraction layer for the resources. Applications and processes use these resources through IPC mechanisms and System calls. • The main tasks of the kernel are : Process management Device management Memory management Interrupt handling I/O communication Shell Kernel Hardware; CPU, I/O, Memory and Storage Devices

Types Of Kernels Monolithic Kernel Microkernel Exokernel Hybrid Kernel Fig. Monolithic Kernel

Types Of Kernels Monolithic Kernel Microkernel Exokernel Hybrid Kernel Fig. Monolithic Kernel

 • Exokernel is an operating system kernel developed by the MIT Parallel and

• Exokernel is an operating system kernel developed by the MIT Parallel and Distributed Operating Systems group, and also a class of similar operating systems. • The idea behind exokernels is to force as few abstractions as possible on developers, enabling them to make as many decisions as possible about hardware abstractions. Fig. Exokernel

 - A hybrid kernel is a kernel architecture based on combining aspects of

- A hybrid kernel is a kernel architecture based on combining aspects of microkernel and monolithic kernel architectures used in computer operating Systems - The idea behind this category is to have a kernel structure similar to a microkernel, but implemented in terms of a monolithic kernel - No performance overhead for message passing and context switching between kernel and user mode, as in monolithic kernels, there are no reliability benefits of having services in user space, as in microkernel. Fig. Hybrid kernel

Types Of kernels

Types Of kernels

2. Unix Kernel • The Unix Kernel is monolithic in design. • The Kernel

2. Unix Kernel • The Unix Kernel is monolithic in design. • The Kernel can be split into two sections : - • machine dependent • and machine independent

User Program Libraries trap User level Kernel level System call Interface Process Control subsystem

User Program Libraries trap User level Kernel level System call Interface Process Control subsystem File Subsystem IPC Scheduler Memory Management Buffer cache Character/block device drivers Hardware control Kernel level Hardware Fig. Block diagram of the system kernel Hardware level

Modern Unix Kernel

Modern Unix Kernel

Examples of modern Unix Systems • System V Release 4[SVR 4] • Solaris 9

Examples of modern Unix Systems • System V Release 4[SVR 4] • Solaris 9 • BSD[Berkeley Software Distribution]

User and Kernel Stack

User and Kernel Stack

Process Table entry Fields • • • PID - unique process identifiers PPID –PID

Process Table entry Fields • • • PID - unique process identifiers PPID –PID of parent User ID state -running, sleeping, . . event descriptor - address of event to wakeup a sleeping process Pointers to page tables size and location of u area & pregion entry - for swapping & switching scheduling parameters determine access to CPU - system priority : user priority array of signals pending execution and kernel utilisation times

u area (user area) fields: • • • pointer to process table entry of

u area (user area) fields: • • • pointer to process table entry of the currently executing process UIDs to permit access rights time spent executing in user and kernel modes an array containing signal handlers login terminal associated with the process error from a system call return value from a system call I/O parameters: amount of data to transfer, the address of the source (or target) data array in user space, file offsets for I/O, etc. current and root directory user file descriptor table records the files the process has open size limits of a process and of a file it can write permission of files the process creates

Data Structure for Process per process region table u area Kernel process table Kernel

Data Structure for Process per process region table u area Kernel process table Kernel region table main memory 17

Context of a process User-level Context - Process Data - User stack - Shared

Context of a process User-level Context - Process Data - User stack - Shared memory Register Context - Program counter - Processor status register - Stack pointer - Shared memory System-level Context -Process table entry - U area - Per process region table - Kernel stack

Process States 8 7 1 3 2 5 6 9 4

Process States 8 7 1 3 2 5 6 9 4

6. Sleep And Wakeup • When process is executing in the kernel it may

6. Sleep And Wakeup • When process is executing in the kernel it may need to wait for some event. • To do this it executes the sleep routine. • Process state changed to blocked and scheduler selects other process. • When the event occurs the interrupt routine executes the wakeup routine. I. e. process state changed from blocked to runnable. • Several processes may be waiting for the same event - all are made runnable. • Interrupts are disabled while sleep and wakeup are executing. • Kernel sets the priority of the sleeping process according to the reason for sleeping.

process A | v Buffer locked sleeps process B : : | | v

process A | v Buffer locked sleeps process B : : | | v Buffer locked sleeps process C : : : | | v Buffer locked sleeps Buffer unlocked. wakeup all sleeping processes A, B, C Ready to run ready to run : Runs buffer : : unlocked : : Lock buffer : : : sleeps for : : some reason : Runs buffer locked : Buffer locked – sleeps Wakes up buffer : Unlocks Buffer : Wakeup all : Ready to run sleeping proc. Ready to run