Untitled
Untitled
Introduction
An operating system is software that manages a computer’s hardware. It also provides a basis for application
programs and acts as an intermediary between the computer user and the computer hardware. The way
components are organized within an operating system has a great impact on its effectiveness and its efficiency.
Thus, an important aspect to consider when designing an operating system is the way it should be structured from
within. However, internal structure of different Operating Systems can vary widely according to many factors. In
this chapter, we are going to describe the components as well as services an operating system provides to users,
and also discuss the various ways of structuring it.
2- Main-memory management
Main-Memory is a large array of words or bytes, each word or byte having its own address. Main memory is a
repository of quickly accessible data shared by the CPU and I/O devices. The major activities of an operating
system in regard to memory-management are:
➢ Keep track of which part of memory are currently being used and by whom
➢ Keep track of unused(“free”) memory
➢ Protect memory space
➢ Decide which processes should be loaded into memory when space becomes available.
➢ Allocate and deallocate memory space as needed.
3- File management
Secondary storage devices are too crude to use directly for long-term storage. The file system provides logical
objects and logical operations on those objects. A file is the basic long-term storage entity: it is a named collection
of persistent information that can be read or written. The file system supports directories, which are special files
that contain names of other files and associated file information. Commonly, files represent programs (both source
OSL1: OPERATING SYSTEM STRUCTURE
and object forms) and data. The operating system is responsible for the following activities in connections with
file management:
➢ The creation and deletion of files and directories.
➢ The support of primitives for manipulating files and directions.
➢ The mapping files onto secondary storage.
➢ The backup of files on stable (non volatile) storage media.
5- Secondary-storage management
Since main memory (primary storage) is volatile and too small to accommodate all data and programs
permanently, the computer system must provide secondary storage to back up main memory. Most modern
computer systems use disks as the principal on-line storage medium, for both programs and data. The operating
system is responsible for the following activities in connection with disk management:
➢ Free space management
➢ Storage allocation
➢ scheduling of disk operations
➢ head movement
➢ Error handling, etc.
6- Protection system
Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user
resources. Protection is a general mechanism throughout the OS. All resources objects need protection (memory,
processes, files, devices). Protection mechanisms help to detect errors as well as to prevent malicious destruction.
The protection mechanism must:
➢ Distinguish between authorized and unauthorized usage.
➢ Specify the controls to be imposed.
System calls are mostly accessed by programs via a high-level Application Program Interface (API) rather than
direct system call use. Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based
OSL1: OPERATING SYSTEM STRUCTURE
systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual
machine (JVM).
➢ Parameters can also be pushed (stored) onto the stack by the program, and the stack popped off by
operating system.
Note: Table and stack methods do not limit the number or length of parameters being passed.
Standard C Library Example: C program invoking printf() library call, which calls write() system call.
OSL1: OPERATING SYSTEM STRUCTURE
Basically, we find a way to build a complex system that’s: effective, reliable and extensible. In this section, we
examine six different structures that have been tried, in order to get some idea of the spectrum of possibilities.
These are by no means exhaustive, but they give an idea of some designs that have been tried in practice. The six
structures are monolithic structure, layered structure, microkernel structure, virtual machines, exokernel
structure, and client-server structure.
2- Layered Approach
Since the beginnings of OS design, people have sought ways to organize the OS to simplify its design and
construction. The Traditional approach is layering: The operating system is divided into a number of layers
(levels), each built on top of lower layers. With modularity, layers are selected such that each uses functions
(operations) and services of only lower-level layers.
The first system constructed in this way was the THE system built at the Technische Hogeschool Eindhoven in
the Netherlands by Edsger Dijkstra and his students in 1968. The system had 6 layers, as shown in Fig.
OSL1: OPERATING SYSTEM STRUCTURE
Layer Function
5 The operator
4 User programs
3 Input/output management
2 Operator-process communication
1 Memory management
Layer 0 dealt with allocation of the Processor. Above layer 0, the system consisted of sequential processes, each
performing a sequential computation. They didn’t have to worry about the fact that multiple processes were
running on a single processor.
Layer 1 did the memory management.
Layer 2 handled communication between each process and the operator console. Above this layer each process
effectively had its own operator console.
Layer 3 took care of managing the I/O devices . Above layer 3 each process could deal with abstract I/O devices
with nice properties, instead of real devices with many peculiarities.
Layer 4 was where the user programs were found. They did not have to worry about process, memory, console,
or I/O management.
The system operator process was located in layer 5.
Each level sees a logical machine provided by lower levels.
level 1 sees “virtual processors”
level 2 sees “Virtual” Memory
level 3 sees a “virtual console”
level 4 sees “virtual” I/O drivers
Note: This approach is not flexible and often has poor performance due to layer crossings.
Exercise: Describe the way Windows 2000 is structured.
In fact, traditionally, with the layered approach, all the layers went in the kernel, but that is not necessary. It would
have been better to put as little as possible in kernel mode because bugs in the kernel can bring down the system
instantly. The idea behind the microkernel design is to achieve high reliability by splitting the OS up into small,
well-defined modules and only one of which, the microkernel, runs in kernel mode. Thus, the other modules just
run as relatively powerless ordinary user processes. In particular, by running each device driver and file system
as a separate user process, a bug in one of these can crash that component, but not the entire system. A few of the
better- known microkernels are: Integrity, K42, L4, PikeOS, QNX, Symbian, and MINIX3.
However, there is performance overhead due to user space-kernel space communication.
4- Client-server model
A slight variation of the microkernel idea is to distinguish two classes of processes, the servers, each of which
provides some services, and the clients, which use these services. This is known as the client-server model. Clients
and servers communicate through message passing. To obtain a service, a client process constructs a message
saying what it wants and sends it to the appropriate server process. The server does the work and sends back the
answer. Messages can be locally transmitted or across a network.
In this model, what the kernel does is to handle communication between clients and servers.
5- Virtual Machines
This approach consists of implementing into one machine many others. i.e one physical machine can hold many
machines called virtual machines, each of them running its set of processes. these virtual machines are exact
copies of the bare hardware, including kernel/user mode, I/O, interrupts, and everything else the real machine has.
Because each virtual machine is identical to the true hardware, each one can run any operating system that will
run directly on the bare hardware. Different virtual machines can run different operating systems. There are 2
approaches to virtualization: Using a type 1 hypervisor(Virtual machine monitor) or a type 2 hypervisor.
In the first approach, there is only one program called Type 1 hypervisor, running on the bare hardware in kernel
mode. Its job is to provide multiple copies of the actual hardware called virtual machines.
OSL1: OPERATING SYSTEM STRUCTURE
In the second approach, there exists an OS (called host OS) actually running on the bare hardware. Type 2
hypervisor is just a user program running on the host OS that creates virtual machines.
In both cases, the OS running on top the hypervisor are called guest OS.
6- Exokernel approach
Rather than just cloning the actual machine, as is done with virtual machines, another strategy is partitioning it,
i.e giving each user a subset of the resources. At the bottom layer, running in kernel mode, is a program called
the exokernel. Its job is to allocate resources to virtual machines and then check attempts to use them to make
sure no machine is trying to use somebody else’s resources.