Duration: 1 Hour Degree: BSCS Course Code: BCS- Semester: 4th
2411
1
Chapter 2
OS design and implementation
Operating Systems
Lecturer: Sana Rehman
2 Design Goals
OS face several problems while designing and implementing
Not all are solvable, but some solutions are possible.
Define goals and specifications.
The design of the system will be affected by the choice of hardware and the type of
system: batch (multiple users using at same time), time sharing (multiple users using
at different times), single user, multiuser, distributed, real time (real time applications),
or general purpose.
Requirements
The requirements can be divided into two basic groups: user goals and system goals.
3 Continued….
User Goals
Users want certain obvious properties in a system.
The system should be convenient to use, easy to learn and to use, reliable, safe, and fast.
System Goals
The system should be easy to design, implement, and maintain; and it should be flexible,
reliable, error free, and efficient.
4
Continued….
There is, in short, no unique solution to the problem of defining the requirements for an
operating system.
The wide range of systems in existence shows that different requirements can result in a
large variety of solutions for different environments.
Specifying and designing an operating system is a highly creative task.
General principles have been developed in the field of software engineering.
5 Mechanism and Policy
One important principle is the separation of policy from mechanism.
Mechanisms determine how to do something; policies determine what will be done.
Example
The timer construct is a mechanism for ensuring CPU protection, but deciding how long
the timer is to be set for a particular user is a policy decision.
The separation of policy and mechanism is important for flexibility.
Policies are likely to change across places or over time
6 Implementation
Once an operating system is designed, it must be implemented.
Operating systems are collections of many programs, written by many people over a long
period of time, it is difficult to make general statements about how they are implemented.
Languages
Early operating systems were written in assembly language.
Some operating systems are still written in assembly language, most are written in a
higher-level language such as C or an even higher-level language such as C++.
An operating system can be written in more than one language.
The lowest levels of the kernel might be assembly language.
Higher-level routines might be in C, and system programs might be in C or C++, in
interpreted scripting languages like PERL or Python, or in shell scripts.
A given Linux distribution probably includes programs written in all of those languages.
7
Continued….
Advantages of using high-level languages
The advantages of using a higher-level language for implementing operating systems are the
same as those gained when the language is used for application programs: the code can be
written faster, is more compact, and is easier to understand and debug.
Improvements in compiler technology will improve the generated code for the entire
operating system by simple recompilation.
An operating system is far easier to port—to move to some other hardware— if it is written
in a higher-level language.
Example
MS-DOS was written in Intel 8088 assembly language.
Consequently, it runs natively only on the Intel X86 family of CPUs.
Can be run on other computers through emulation (reproduction of a function of another
computer)
Emulators are programs that duplicate the functionality of one system on another system.
Disadvantages of implementing an operating system in a higher-level language are reduced
speed and increased storage requirements.