Kernels - notes PDF

Title Kernels - notes
Course Computer Operating Systems
Institution University of Miami
Pages 3
File Size 98 KB
File Type PDF
Total Downloads 60
Total Views 123

Summary

notes...


Description

Kernels August 27, 2010 The kernel is (almost) a single program. It is the first code loaded of you operating system. When you “boot” a system, you are reading the kernel program off the boot device, placing it in memory, and then running that program.   

For linux, your kernels are, e.g. /boot/vmlinuz-2.6.18-194.3.1.el5 For OSX, the kernel is /mach_kernel For Windows NT, it is C:Winnt\System32\Ntoskrnl.exe

It is of considerable importance that the kernel runs in a privileged mode. The CPU has privilege levels, implemented in its hardware, that limits the capability of the CPU according to level. The set of instructions that are enabled, the memory addresses that can be accessed, the registers or other hardware units that are available, are all dependent on the privilege mode. The processor enters into privileged mode when it encounters a system trap. Faults and programming errors cause system traps, but deliberate entry into the privileged mode can occur by running a trap instruction. A trap is very similar to subroutine call except that the address of the call is carefully managed, and a the processor privilege is raised by the trap. When not in privileged mode, the CPU is said to be in user mode, often said that the programs are running in user land. Everything you have ever written up to this point in your life, I’d make a fair wager, ran and runs in user land. Kernels have an architecture. The architecture is useful to break down the large task of writing a kernel into smaller pieces. The architecture can also be guided by operating system principals, by philosophy, and by fashions and fads. The simplest and oldest kernel architecture is “one big program”, and this is called the monolithic kernel. The monolithic kernel continues to be the style of many of the unix variants, including Linux and FreeBSD, moderated by the fact that these kernels support extensions, called modules, and a great deal of the kernel is not loaded as part of one big program, but brought in by the core kernel as modules. In Linux these modules are located in /lib/modules/_kernel_name_/ Some more information about unix is here:   

IBM Kernel introduction Bell Labs introduction my introduction

The unix shell While there is a tendency to see the console program, and the command line interface of Unix, as the operating system, that program is a somewhat optional element of the operating system, called the shell. Unix was created with no preference for a particular shell, although there is a default shell in a default install. This is the program /bin/sh and at the time of this writing is more precisely called the Bourne shell, after the author, Stephen Bourne. The shell is the face of the operating system. In the sense of Stallman’s definition of operating system, the shell is part of the operating system. On the other hand, it is just a program written to deal with a very well defined interface with the kernel. The shell is always programmable. It is equally at home taking commands from the user interactively as it is taking a “program”, called a shell script, and running the commands dictated by the script. For that reason, all unix shells have support for if-else statements, loops, variables, etc, all the things for a programming language.

Use of shell scripts is very common and important in unix. There are other programs that form the operating system. In unix and all its variants, the kernel boots the rest of these programs. The kernel runs entirely in privileged space. The kernel creates the first user space program, called /sbin/init, and this program starts up all the rest of the operating system. For maximum flexibility, it does this by running a series of shell scripts. Init itself knows very little about the details of its job. That knowledge is in shell scripts. The shell script locations vary according to unix variant, even down to the distro of linux, which is one particular variant of linux. In Ubuntu, they are in /etc/init.d and the various /etc/rcX.d directories. You should boot a linux machine now and identify the kernel loading process, and read the messages produced by the kernel during boot. You should identify when the “greater operating system” comes on line, in turn booted by the kernel, and often called run levels. The Anatomy of the Linux Kernel Kernels are complicated programs, and their functionality is broken down into components. The Linux kernel is broken down by system including: process management, memory management, the virtual file system (VFS), implementations backing the VFS, the networking stack, the system call interface (SCI) and other trap management, and device drivers. The style of the Linux kernel is a monolithic kernel, meaning that although the code is divided into subsystems, the division is entirely voluntary. When the process management needs services from memory management, there will be subroutines made directly from one system to the other. The compiler will link together all the subsystems to facilitate crossing subsystem boundaries. A map of the Linux kernel gives an idea of the complexity of the over 4 million lines of code in the 2.6 Linux kernel. (See The Linux Kernel: It’s Worth More!) Process management: The kernel subsystems follow the main operating systems abstractions as they are covered in this course. A process is a container for an environment in which a program runs; it is also those mechanisms to control the running of the program, and more accurately, the threads of control (or more simply said: threads) that effectuate the work of the program. As examples of things in the process environment: the actual code to be run is loaded into the environment, tags of process ownership and privilege, perhaps to regulate access to files, and claims on physical resources such as memory, keyboard, or mouse. Memory management: A crucial resource for the running of programs is memory. Memory is abstracted as a virtual memory space private to each process environment. That abstraction is realized by assigning physical memory, either fast RAM or slower disk, to “back” the virtual memory abstraction. File systems: File systems are a sort of memory, however they are a special sort of memory that supports persistence — the long term storage of data in a sharable, flexibly retrievable format. To facilitate the matching between the ideal of a file system and a specific implementation of that ideal, a Virtual File System (VFS) is defined internal to the kernel. The VFS interface presents a standard set of actions such as open, read, and depending on the implementation’s capabilities, perhaps seek. A file system implementation lies behind the VFS interface and carries out the requested actions, and delivers the expected functionality. A file system implementation might use the capabilities of a disk to store information, or it might implement a network file system that sends data blocks across the network to be stored to retrieved in some manner by the file server at the other end of the network connection. A disk based file system might be optimized for speed for streaming files, or for fast retrieval of structure data. File systems generally support folders, however the swap file system, which works in coordination with memory management, is an example of a file system without file names or folders.

In many cases, the connection between the file system and threads running in processes is through the VFS, isolating implementation details of the file system from the using process. Device drivers: The kernel interfaces between the hardware and upper level software, particularly user software expecting to exploit the capabilities of the hardware. Kernel software responsible for the direct interface with the hardware is isolated into device drivers. Device drivers are written to standards that allow them to be pluggable: when a new device is added, the device driver can be pulled from a library of drivers, added to the kernel’s software and attached to the appropriate hooks, and start communications between the hardware and the kernel. Trap Management including the SCI: The interface between user software and the kernel is via the system call interface (SCI) which works by a special hardware event called a software trap. The boundary between user and kernel software has hardware supported protection, and there are a only a few well orchestrated events that transition over the boundary. The SCI is important, as we will be taking about it first. Besides the SCI system trap, which is an exception to code flow explicitly caused by the execution of a special trap instruction, there are several other sorts of traps with vary various causes. Some are caused by hardware events, and are called interrupts, and some are cause by software faults. A fault of particular interest is the page fault, which occurs when the processor attempts to access virtual memory which the memory management system has not yet backed by physical memory. The kernel is responsible for handling interrupts, traps, faults, and other exceptions, typically dispatching to other subsystems to handle the event, and providing for a path back to resume the interrupted computation. Networking Stack: The Linux kernel also includes the software for handling network communications. Implementation of network communications requires activity extending from the networking hardware, up through various routing and and communication protocols, until it is presented as the socket communication abstraction for read and write by user programs. Because of the number of different and well defined levels of activity, the networking system is called the networking stack. It works in coordination with a great number of administration programs run outside of the kernel. Hardware abstraction layers: Many operating systems use a Hardware Abstraction Layer, or HAL, to make the actual kernel less platform dependent. The HAL attempts to abstract away details between, say, particular chips. Properly done, when porting a kernel to a new hardware platform, only the HAL needs to be changed....


Similar Free PDFs
Notes
  • 18 Pages
Notes
  • 12 Pages
Notes
  • 61 Pages
Notes
  • 35 Pages
Notes
  • 19 Pages
Notes
  • 70 Pages
Notes
  • 6 Pages
Notes
  • 35 Pages
Notes
  • 29 Pages
Notes
  • 70 Pages
Notes
  • 6 Pages
Notes
  • 19 Pages
Notes
  • 32 Pages