Unix Kernel Architecture:The Scheduler and Linux Kernel.
The Scheduler
Most Unix schedulers follow the rules given below for scheduling:
1. Usually a scheduler reevaluates the process priorities at 1 second interval. The system maintains queues for each priority level.
2. Every tenth of a second the scheduler selects the topmost process in the runnable queue with the highest priority.
3. If a process is runnable at the end of its allocated time, it joins the tail of the queue maintained for its priority level.
4. If a process is put to sleep awaiting an event, then the scheduler allocates the processor to another process.
5. If a process awaiting an event returns from a system call within its allocated time interval but there is a runnable process with a higher priority then the process is interrupted and higher priority, process is allocated the CPU.
6. Periodic clock interrupts occur at the rate of 100 interruptions per second. The clock is updated for a tick and process priority of a running process is decremented after a count of 4 ticks. The priority is calculated as follows:
priority = (CPU quantum used recently)/(a constant) + (base priority) + (the nice setting).
Usually the priority diminishes as the CPU quantum rises during the window of time allocated. As a consequence compute intensive processes are penalised and processes with I/O intensive activity enjoy higher priorities.
In brief:
• At every clock tick: Add 1 to clock, recalculate process priority if it is the 4th clock tick for this process.
• At every 1/10th of the second: Select process from the highest priority queue of runnable processes.
• Run till:
1. End of the allocated time slot or2. It sleeps or3. It returns from a system call and a higher priority process is ready to run.
• If it is still ready to run: It is in runnable state, so place it at the end of process queue with the same priority level.
• At the end of 1 second: Recalculate the priorities of all processes. Having seen the Unix Kernels' structure and operation, let us look at Linux.
Linux Kernel
The Linux environment operates with a framework having four major parts. These sections are: the hardware controllers, the kernel, the OS services and user applications. The kernel as such has a scheduler. For specialised functions, the scheduler makes a call to an appropriate utility. For instance, for context switching there is an assembly program function which the scheduler calls. Since Linux is available as open source we can get the details of the kernel internals function. For instance, the source description of the scheduler is typically located at /usr/src/linux/sched.c. This program regulates the access of processes to the processor. The memory management module source is at /usr/src/linux/mm. This module supports virtual memory operations.
The VFS or virtual file system takes into a variety of file formats. The VFS is a kind of virtual file interface for communication with the devices. The program at /usr/src/linux/net provides the basic communication interface for the net. Finally, the programs at /usr/src/linux/ipc define the range of inter-process communication capabilities. The net and VFS require device drivers usually found at /usr/src/linux/drivers. The architecture x dependent code, essentially, assembly code is found at /usr/src/linux/arch and /usr/src/linux/include. Between them these define and offer all the configuration information which one may need. For instance, one can locate architecture specific files for processors like i386 and others. Lastly, as mentioned earlier, the Linux kernel uses some utilities written in assembly language instructions to do the process switching.
14.6.1 Linux Sources and URLs
Linux, as we stated earlier, is an open source. The following URLs offer a great deal of information about Linux.
1. www.linux.org The most sought after site for Linux. It gives all the user driven and developed information on Linux.
2. sunshine.unc.edu/mdw/linux.html The home page of linux documentation.
7. The following three URLS are for linux administration, open source gnu c compiler and Linux kernel. linux.dev.admin linux.dev.gcc linux.dev.kernel Now that we have studied Unix kernel, we shall reinforce the tools track. The next module shall deal with make tool and its use in large projects.
Comments
Post a Comment