ADAMA UNIVERSITY SCHOOL OF ENGENEERING & INFORMATION TECHNOLOGIES 1 - 1 OPERATING SYSTEM (IT3016)
Mar 26, 2015
ADAMA UNIVERSITYSCHOOL OF ENGENEERING &
INFORMATION TECHNOLOGIES
1-1
OPERATING SYSTEM (IT3016)
Major Topics
Sem II-2011 3rd year G5-G81-2
Chapter 1Introduction to OPERATING SYSTEM
and Its structures
Introduction
Sem II-2011 3rd year G5-G81-4
Computer software can be divided roughly into two kinds:
1. System software:- which manages the operation of the computer itself.
2. Application programs:-which performs the actual work the user wants.
The most important system program is the operating system (OS), whose job is to control all the computer's resources and provide a base upon which the application programs can be written.
The OS controls and coordinates the use of the hardware among the various system programs and application programs for a various users.
It simply provides an environment with which other programs can do useful work.
Definition and Objectives of an Operating System
Sem II-2011 3rd year G5-G81-5
Definition: Os is a System program thatcontrols execution of programs to prevent errors and
improper use of the computer. acts as an interface between the hardware and its users.
Objectives:Convenience – Top Down View – Virtual
MachineExtending the real hardware and acting as a Virtual MachineHiding the truth about the hardware from the userProviding the user a convenient interface which is easier to program
Efficiency – Bottom Up View – Resource ManagerProviding an orderly and controlled allocation of resourcesImproving resource utilizationManages all resources
Sem II-2011 3rd year G5-G81-6
Ability to EvolveAdaptability to new changes
Hardware upgrades/New types of hardwareNeed of new services
Easy fixes of latent errors Operating Systems and Computer Architecture are historically tied because architectural changes affect both
structure of Operating Systemsperformance of Operating Systems
Operating system goals can be summarized as:
I. Execute user programs and make solving user problems easier.
II. Make the computer system convenient to use.
III. Use the computer hardware in an efficient manner.
Computer System Structure
Sem II-2011 3rd year G5-G81-7
Computer system can be divided into four componentsHardware – provides basic computing
resourcesCPU, memory, I/O devices
Operating systemControls and coordinates use of hardware among
various applications and usersApplication programs – define the ways in
which the system resources are used to solve the computing problems of the usersWord processors, compilers, web browsers, database
systems, video gamesUsers
People, machines, other computers
Four Components of a Computer System
Sem II-2011 3rd year G5-G81-8
Sem II-2011 3rd year G5-G81-9
A computer system can be viewed as a system consisting of hardware, software and data.─ Os provides the means for proper use of these
resources─ An Os is like a government, which does not
perform any useful function by itself. But it simply provides an environment so that other programs can perform useful work.
Operating system role’s─ Two views
a. User view─ The user view of a computer system depends on
the types of interfaces being used.1.One PC-one user: -a single user monopolizes all the
resources that a single PC has. Objective-maximizes work. but no resource sharing
COMPUTER SYSTEM…
Sem II-2011 3rd year G5-G81-10
2. Users at terminals:-a user sits at a terminal connected to a main frame or a minicomputer. Other users can have access to this same mainframe. Users also may exchange information.
objective:-maximizes resource-sharing(the OS must assure that no individual user consumes more than its fair share)
3. Users at workstations connected to networks of other workstations
Users have individual resources at their disposal but also share resources such as networks and servers-file, printers ,etc. so an OS designed for such purpose must compromise b/n individual usability & resource utilization.
4. Handheld computers:-most are standalone & for individual use. They might be wired/less/. OS designed for these systems maximizes individual usability but performance per amount of power must be an issue.
COMPUTER SYSTEM STRU….
Sem II-2011 3rd year G5-G81-11
System view:-from the computers point of viewThe OS is most intimately involved program with the
hardware1.The OS is a resource manager. Since it manages
CPU time, memory space, storage space ,I/O devices and so on which are used by the computer system in solving problem. OS manages d/t requests that may conflict with each other and assigns them the available resources fairly.
o The OS can deallocate a resource when the program to which it is allocated either terminates or makes an explicit request for deallocation.
o Alternatively, it can deallocate a resource by force. This actions is called resource preemption.o System resources may be preempted by an OS to
enforce fairness in their use by programs, or to realize certain system-level goals.
COMPUTER SYSTEM STRU….
Sem II-2011 3rd year G5-G81-12
o A preempted program can not execute unless the preempted resource unit, or some resource unit of the same resource class, is allocated to it.
Resources can be shared by a set of programs in two ways: o Sequential sharing:- a resource is allocated for
exclusive use by a program. When the resource is deallocated, it is marked as free in the resource table so that it will be allocated to another program.
o Concurrent sharing:- two or more programs can concurrently use the same resource.
o The CPU can be shared only in sequential manner where as the memory can be shared in both sequential as well as pool-based manner.
COMPUTER SYSTEM STRU….
Sem II-2011 3rd year G5-G81-13
2. OS is a control program. It manages the execution of user programs to prevent errors and improper use of the computer. It is especially concerned with the operation and control of I/O devices.
The fundamental goal of a computer system is to execute user programs and make solving user problems easier. For this purpose computer hardware was constructed. But bare hardware is not used for this purpose. This leads to the development of application programs.
Application programs have certain common operations, such as controlling I/O devices. The common functions of controlling and allocating resources are brought together into a piece of software called OS.
COMPUTER SYSTEM STRU….
Sem II-2011 3rd year G5-G81-14
Operating System Definition OS is a resource allocator
Manages all resourcesDecides between conflicting requests for efficient and
fair resource use OS is a control program
Controls execution of programs to prevent errors and improper use of the computer
No universally accepted definition“Everything a vendor ships when you order an
operating system” is good approximationBut varies wildly
“The one program running at all times on the computer” is the kernel. Everything else is either a system program (ships with the operating system) or an application program
Operating System Functions
Sem II-2011 3rd year G5-G81-15
Can be summarized into two broad functions:1. Resource Management
Time management - CPU and disk transfer schedulingSpace management - main and secondary storage
allocationSynchronization and deadlock handling - IPC, critical
section, coordinationAccounting and status information - resource usage
tracking2. User Environment monitoring- OS layer transforms bare
hardware machine into higher level abstractionsExecution environment - process management, file
manipulation, interrupt handling, I/O operations, language.Error detection and handlingProtection and securityFault tolerance and failure recovery
Examples of where you will find OSs
Sem II-2011 3rd year G5-G81-16
1. Servers (Mainframe Computers):- specialized for processing large volumes of requests for a given service. Generally has a large number of necessary resources.
2. Desktops:- specialized for single-user (or
limited number of users). o Generally has a GUI that is integral to system software
o designed to minimize response time to user requests
o May run several different types of operating systems
(Windows, MacOS, UNIX, Linux).
3. Embedded Systems:- specialized for managing a limited number of resources such as power, memory, I/O speed.
PDAs, cell phones, smart cards, automobiles.
Examples of where you will find …
Sem II-2011 3rd year G5-G81-17
4. Clustered (Message-passing multicomputer) Systems:- are interconnected by a high-speed interconnection fabric. Each processor has its own local memory and they communicate using the interconnect.
May share secondary storage.5. Real-time Systems:- Specialized systems that must
meet stringent performance and behavior requirements.
RTOS is one that must react to inputs and responds to them quickly.
6. Distributed Systems Distribute the computation among several physical
processors. Distributed OS runs on and controls the resources of
multiple machines.
Examples of where you will find …
Sem II-2011 3rd year G5-G81-18
7. Parallel Systems
Multiprocessor systems with more than on CPU in close
communication.
8. Multiprogrammed Batch System Several jobs are kept in main memory at the same time,
and the CPU is multiplexed among them.
9. Time-Sharing Systems–Interactive Computing
Time-sharing systems supports interactive users.
It is also called multitasking and it is a logical extension of
multiprogramming.
Time-sharing systems uses CPU scheduling and
multiprogramming to provide an economical interactive system
of two or more users.
Here each user is given a time-slice for executing his job in
round robin fashion. Job continues until the time-slice ends.
Computer Startup
Sem II-2011 3rd year G5-G81-19
bootstrap program is loaded at power-up or rebootTypically stored in ROM or EPROM, generally known
as firmwareInitializes all aspects of systemLoads operating system kernel and starts execution
Computer System OrganizationComputer-system operation
One or more CPUs, device controllers connect through common bus providing access to shared memory
Concurrent execution of CPUs and devices competing for memory cycles
Sem II-2011 3rd year G5-G81-20
Computer-System Operation I/O devices and the CPU can execute concurrently.Each device controller is in charge of a particular device
type.Each device controller has a local buffer.CPU moves data from/to main memory to/from local
buffers I/O is from the device to local buffer of controller.Device controller informs CPU that it has finished its
operation by causing an interrupt.
Storage Structure
Sem II-2011 3rd year G5-G81-21
Main memory – the only large storage media that the CPU can access directly.
Secondary storage – extension of main memory that provides large nonvolatile storage capacity.
Magnetic disks – rigid metal or glass platters covered with magnetic recording material Disk surface is logically divided into tracks, which are
subdivided into sectors. The disk controller determines the logical interaction
between the device and the computer.
Storage-Device Hierarchy
Sem II-2011 3rd year G5-G81-22
Caching
Sem II-2011 3rd year G5-G81-23
Important principle, performed at many levels in a computer (in hardware, operating system, software)
Information in use copied from slower to faster storage temporarily
Faster storage (cache) checked first to determine if information is thereIf it is, information used directly from the cache
(fast)If not, data copied to cache and used there
Cache smaller than storage being cachedCache management important design problemCache size and replacement policy
Performance of Various Levels of Storage
Sem II-2011 3rd year G5-G81-24
Movement between levels of storage hierarchy can be explicit or implicit
Computer system structure
Sem II-2011 3rd year G5-G81-25
A computer system can be categorized into a number of ways based on the number of general purpose processors used.
1. single processor systems─ most systems belongs to this category─ ranges from PDAs to main frames─ have one main CPU capable of executing a
general purpose instruction set, including instructions from user process.
─ The use of a special purpose processor does not change a single-processor system into multiprocessor.
Sem II-2011 3rd year G5-G81-26
2. Multiprocessor system─ also called parallel systems or tightly coupled
systems─ have 2 or more general purpose processors in close
communications, sharing the computer bus and sometimes the clock, memory and peripherals.
─ Has three main advantagesa. Increased throughputb. Economy of scalec. Increased reliability
i. increased throughput.─ Increasing number of processors =>more work done
in less time.─ The speedup ratio of N-processors is not N. Rather it
is less than N(cause- the overhead incurred in keeping all parts working together plus contention for shared resources)
COMPUTER SYSTEM STRUCTURE(CONT)
Sem II-2011 3rd year G5-G81-27
ii. Economy of scale-multiprocessor systems cost less than equivalent multiple single processor systems, because they can share peripherals, mass storage, and power supplies .
─ If several programs operates on the same set of data, it is cheaper to store those data on one disk and to have all the processors share them than to have many computers with local disks and many copies of the data.
iii. Increased Reliability.─ Functions being distributed properly among several
processors, failure of one processor will not halt the system, only slow it down.
─ If 10 processors are there and if one fails, then each of the remaining 9 processors can pickup a share of the work of the failed processor.==>the entire system runs only 10% slower, rather than failing altogether.
COMPUTER SYSTEM STRUCTURE(CONT)
Computer system structure(cont)
Sem II-2011 3rd year G5-G81-28
The ability to continue providing proportional service to the level of surviving hardware is called graceful degradation.(Exc. Compare it with fault tolerant).
Multiprocessors are two typeso Asymmetric multiprocessorso Symmetric multiprocessors
Asymmetric multiprocessorsEach processor is assigned a specific task. A
master processor controls the system; the other processors either look to the master for instruction or have predefined tasks.
Defines a master-slave relationshipsThe master processor schedules and allocates
work to the slave processors.
Computer system structure(cont)
Sem II-2011 3rd year G5-G81-29
Symmetric multiprocessors(SMP) Each processor performs all tasks within the operating
system. SMP-means all processors are peers benefit-many processes can run simultaneously.3. clustered Systems
─ is a type of multi-CPU system ─ Have multiple CPUs to accomplish computational
work(like multiprocessor systems)─ They are composed of two or more individual
systems coupled together(difference with multiprocessors)
─ They share storages and are closely liked via a LAN or faster interconnect such as InfiniBand.
─ Provide high availability service(service will continue even if one or more systems in the cluster fail)
Computer system structure(cont)
Sem II-2011 3rd year G5-G81-30
Clustering can be a. asymmetric mode─ One machine is in hot-stand-by mode, while
the other is running the application.─ The HSM host machine does nothing but
actively monitors the server. If server fails, the HSM become the active server.
b. Symmetric mode─ Two or more hosts are running applications,
and are monitoring each other.─ More efficient as it uses all of the available
hardware.
Operating System Structure
Sem II-2011 3rd year G5-G81-31
Multiprogramming needed for efficiencySingle user cannot keep CPU and I/O devices busy
at all timesMultiprogramming organizes jobs (code and data)
so CPU always has one to executeA subset of total jobs in system is kept in memoryOne job selected and run via job schedulingWhen it has to wait (for I/O for example), OS
switches to another job.Timesharing (multitasking) is logical
extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computingResponse time should be < 1 second
Sem II-2011 3rd year G5-G81-32
Each user has at least one program executing in memory process
If several jobs ready to run at the same time CPU scheduling
If processes don’t fit in memory, swapping moves them in and out to run
Virtual memory allows execution of processes not completely in memory
VM enables users to run programs that are larger than actual physical memory
OPERATING SYSTEM STRUCTURE(CONT)
Memory Layout for Multiprogrammed System
Sem II-2011 3rd year G5-G81-33
Processor switches from one process
to an other when
ever an I/O event or Timer interrupt occurs
Figure :-4 processes are loaded to memory in Multiprogramming
systems
Operating System Components
Sem II-2011 3rd year G5-G81-34
All OSs have similar core componentsShell(User level)Kernel (core)
The shell exposes functions to users and applicationsPiece of software that provides an interface for users
using either command-line or graphical interfaceActs as an interface between the user and the kernel.Normally reside on disks and are loaded into memory
when needed.The kernel (nucleus) interacts with hardware devices
Allocates time & memory to programs and handles the file store & communication in response to system calls
Reside in memory all the time and is the hub of the OS
Operating-System Operations
Sem II-2011 3rd year G5-G81-35
Modern OS are interrupt driven.Software error or request creates exception
or trapDivision by zero or invalid memory access.
Other process problems include infinite loop, processes modifying each other or the operating system
Dual-mode operation allows OS to protect itself and other system componentsUser mode and kernel mode Mode bit provided by hardware
Provides ability to distinguish when system is running user code or kernel code
Some instructions designated as privileged, only executable in kernel mode
System call changes mode to kernel, return from call resets it to user
Sem II-2011 3rd year G5-G81-36
During a transition from User to Kernel Mode an infinite loop may occur.
To prevent infinite loop / process hogging resources a Timer is used.how?o Set interrupt after specific periodo Operating system decrements countero When counter zero generate an interrupto Set up before scheduling process to regain control or
terminate program that exceeds allotted timeA computer system executing tasks on behalf of a user
applications, the system is in user mode. When a user application requests service from an OS(via
system call) it is in kernel mode. At system boot time, the hardware starts in kernel mode. Then
the OS is loaded and starts execution of user applications in a user mode.
System call provide the means for a user program to ask the OS to perform tasks reserved for the OS on the user’s programs behalf.
Operating system services
Sem II-2011 3rd year G5-G81-37
User interface:-command line or GUIProgram execution:-I/O operationsFile System ManipulationsCommunicationError detectionResource allocationAccountingProtection and Security
Operating System Services
Sem II-2011 3rd year G5-G81-38
Below are some of the main services of the operating system that provides helpful functions to the user.User interface - Almost all operating systems have a
user interface (UI) Varies between Command-Line (CLI), Graphics User Interface (GUI),
Batch
Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)
I/O operations - A running program may require I/O, which may involve a file or an I/O device.
File-system manipulation - programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
Operating System Services (Cont.)
Sem II-2011 3rd year G5-G81-39
Communications – Processes may exchange information, on the same computer or between computers over a networkCommunications may be via shared memory or
through message passing (packets moved by the OS)Error detection – OS needs to be constantly aware of
possible errorsAn error may occur in the CPU and memory
hardware, in I/O devices, in user programFor each type of error, OS should take the
appropriate action to ensure correct and consistent computing
Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system
Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated Fairley to each of them
Operating System Services (Cont.)
Sem II-2011 3rd year G5-G81-40
Many types of resources - Some (such as CPU cycles, Main memory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code.
Accounting - To keep track of which users use how much and what kinds of computer resources
Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other
Protection involves ensuring that all access to system resources is controlled
Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts
If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.
User Operating System Interface - CLI
Sem II-2011 3rd year G5-G81-41
CLI allows direct command entrySometimes implemented in kernel, sometimes by
systems programSometimes multiple flavors implemented – shellsTwo approaches
Primarily fetches a command from user and executes it
commands are just names of programsoIn the latter, adding new features doesn’t require shell modification
User Operating System Interface - GUI
Sem II-2011 3rd year G5-G81-42
User-friendly desktop metaphor interfaceUsually mouse, keyboard, and monitorIcons represent files, programs, actions, etcVarious mouse buttons over objects in the
interface cause various actions (provide information, options, execute function, open directory (known as a folder)
Invented at Xerox PARCMany systems now include both CLI and GUI
interfacesMicrosoft Windows is GUI with CLI “command”
shellApple Mac OS X as “Aqua” GUI interface with UNIX
kernel underneath and shells availableSolaris is CLI with optional GUI interfaces (Java
Desktop, KDE)
System Calls
Sem II-2011 3rd year G5-G81-43
are ready-made functions comprises of frequently used code(such as device controlling codes-which may waste programmers time if programmers write them)
Provide an interface to allow user-level processes to request services of the operating system.
Typically written in a high-level language (C or C++), but some are written in assembly and machine languages.
The next slide shows the sequence of system calls used in copying data from one file to another file.
Example of System Calls
Sem II-2011 3rd year G5-G81-44
System call sequence to copy the contents of one file to another file.
even simple programs make heavy use of the operating system. But most programmers do not see this level of detail.
Sem II-2011 3rd year G5-G81-45
Usually application developers design programs based on Application Programming Interface(APIs).
APIs specify a set of functions that are available to an application programmer, including the parameters used for each function including the return type a programmer expect.
Most programs access system calls via APIs, rather than direct system call.
Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM)
Why did an application programmer prefer programming according to APIs instead of invoking direct system calls?Portability:-program designed in APIs can compile
and run on other systems sporting the same APIs.Convenience : Actual sys calls are usually more
detail and difficult to work with than the API available to app programmer.
Example of Standard API
Sem II-2011 3rd year G5-G81-46
Consider the ReadFile() function in the Win32 API—a function for reading from a file
A description of the parameters passed to ReadFile() HANDLE file—the file to be read LPVOID buffer—a buffer where the data will be read into
and written from DWORD bytesToRead—the number of bytes to be read
into the buffer LPDWORD bytesRead—the number of bytes read during
the last read LPOVERLAPPED ovl—indicates if overlapped I/O is being
used(Note that the system-call names used throughout this presentation are generic, each operating system has its own name for each system call)
System Call Implementation
Sem II-2011 3rd year G5-G81-47
Typically, a number associated with each system callSystem-call interface maintains a table indexed
according to these numbersThe system call interface invokes intended
system call in OS kernel and returns status of the system call and any return values
The caller need know nothing about how the system call is implementedJust needs to obey API and understand what OS will
do as a result callMost details of OS interface hidden from programmer
by API Managed by run-time support library (set of
functions built into libraries included with compiler)
API – System Call – OS Relationship
Sem II-2011 3rd year G5-G81-48
Standard C Library Example
Sem II-2011 3rd year G5-G81-49
C program invoking printf() library call, which calls write() system call
Sem II-2011 3rd year G5-G81-50
Example:-to make clear how a systems call works, consider a read system call with signature as follows.
- read(fd,&buffer,nbytes); A call from a C program might look like this;
- count=read(fd,&buffer,nbytes); System calls are performed in a number of steps: - to see
the steps consider the read system call discussed above.
System Call Parameter Passing
Sem II-2011 3rd year G5-G81-51
Often, more information is required than simply identity of desired system callExact type and amount of information vary
according to OS and call Three general methods are used to pass parameters
between a running program and the operating system.Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register This approach taken by Linux and Solaris
Parameters placed on stack:- parameters are pushed onto the stack by the program and popped off the stack by the operating systemBlock and stack methods do not limit the number or
length of parameters being passed
Exp
lain
how
para
mete
rs a
re e
xch
an
ged
b
etw
een
pro
ced
ure
s du
rin
g a
syst
em
call
Parameter Passing via Table
Sem II-2011 3rd year G5-G81-52
Types of System Calls
Sem II-2011 3rd year G5-G81-53
System Programs(cont)
Sem II-2011 3rd year G5-G81-54
System programs provide a convenient environment for program development and execution. The can be divided into:File manipulation Status informationFile modificationProgramming language supportProgram loading and executionCommunicationsApplication programs
Most users’ view of the operation system is defined by system programs, not the actual system calls
Sem II-2011 3rd year G5-G81-55
Provide a convenient environment for program development and execution
Some of them are simply user interfaces to system calls; others are considerably more complex
File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories
Status informationSome ask the system for info - date, time, amount of
available memory, disk space, number of usersOthers provide detailed performance, logging, and
debugging informationTypically, these programs format and print the
output to the terminal or other output devicesSome systems implement a registry - used to store
and retrieve configuration information
SYSTEM PROGRAMS(CONT)
System Programs (cont’d)
Sem II-2011 3rd year G5-G81-56
File modificationText editors to create and modify filesSpecial commands to search contents of files
or perform transformations of the textProgramming-language support -
Compilers, assemblers, debuggers and interpreters sometimes provided
Program loading and execution- Absolute loaders, relocatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language
Communications - Provide the mechanism for creating virtual connections among processes, users, and computer systemsAllow users to send messages to one
another’s screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another
Operating System Design and Implementation
Sem II-2011 3rd year G5-G81-57
Design and Implementation of OS not “solvable”, but some approaches have proven successful
Internal structure of different Operating Systems can vary widely
Start by defining goals and specifications Affected by choice of hardware, type of systemUser goals and System goals
User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast
System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient
System Implementation
Sem II-2011 3rd year G5-G81-58
Traditionally written in assembly language, operating
systems can now be written in higher-level languages.
Code written in a high-level language:
can be written faster.
is more compact.
is easier to understand and debug.
An operating system is far easier to port (move to
some other hardware) if it is written in a high-level
language.
System Generation (SYSGEN)
Sem II-2011 3rd year G5-G81-59
Operating systems are designed to run on any of a class
of machines; the system must be configured for each
specific computer site.
SYSGEN program obtains information concerning the
specific configuration of the hardware system.
Booting:- starting a computer by loading the kernel.
Bootstrap program:- code stored in ROM that is able to
locate the kernel, load it into memory, and start its
execution.
Operating System Structure
Sem II-2011 3rd year G5-G81-60
Modern operating systems are complex and consists of different components.
These components of modern systems are interconnected and melded to the kernel.
five different OS structures have been tried so far.
The five designs are:
a.monolithic systems
b.layered systems
c.virtual machines
d.Microkernel’s and
e.modules
I. Monolithic Systems
Sem II-2011 3rd year G5-G81-61
written to provide the most functionality in the least spaceNot divided into modules
It is a simple structure.
The operating system is written as a collection of procedures,
each of which can call any of the other ones whenever it needs
to.
When this technique is used, each procedure in the system
has a well-defined interface in terms of parameters and
results, and each one is free to call any other one, if the
latter provides some useful computation that the former
needs.
In this approach, software is characterized by the fact that
different parts of the software know each other’s internal
details and freely use this knowledge in their functioning (no
data hiding).
Sem II-2011 3rd year G5-G81-62
The following are draw backs of monolithically structured OS:
Each OS component is machine dependent, that is,
each component has to interface with the
computer hardware (bare machine).• This made OS development difficult, time consuming and
expensive.
A change made in one monolithic software
component can affect its other components. This is
due to the reason that different components of the
monolithic software share each other’s data.
Testing and debugging is difficult. MS-DOS is an example of such OSs.
MONOLITHIC SYSTEMS(CONT)
Simple Structure
Sem II-2011 3rd year G5-G81-63
MS-D
OS L
AYER
STR
UC
TU
RE
MONOLITHIC SYSTEMS(CONT)
II. Layered Approach(Design)
Sem II-2011 3rd year G5-G8
64
Were developed in which functions are organized hierarchically and interaction only takes place between adjacent layers.
The operating system is divided into a number of layers (levels), each built on top of lower layers.
The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.
With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers.
In layered approach, most or all of the layers execute in kernel mode.
The basic discipline in layered OS design is that the routines of one layer use only the facilities of the layer directly below it, that is, no layer in the structure can be bypassed.
Sem II-2011 3rd year G5-G81-65
The OS is designed to organize the operating system as a
hierarchy of layers, each one constructed upon the one
below it.
The first system constructed in this way was the THE
system built at the Technische Hogeschool Eindhoven in
the Netherlands by E. W. Dijkstra and his students.
LAYE
RE
D O
PE
RA
TIN
G
SYS
TE
M
LAYERED APPROACH(CONT
Sem II-2011 3rd year G5-G81-66
The layered approach suffers from two problems:
1. The operation of a system be slowed down by the layered structure. Each layer adds a system call overhead.
2. The second problem concerns difficulties in developing a layered design.
UNIXUNIX – limited by hardware functionality, the
original Unix operating system had limited structuring. The Unix OS consists of two separable parts Systems programs The kernel
Consists of everything below the system-call interface and above the physical hardware
Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level
LAYERED APPROACH(CONT)
III.Virtual Machines
Sem II-2011 3rd year G5-G81-67
A virtual machine takes the layered approach to its logical conclusion.
It treats hardware and the operating system kernel as though they were all hardware.
A virtual machine provides an interface identical to the underlying bare hardware.
The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory.
The resources of the physical computer are shared to create the virtual machines. CPU scheduling can create the appearance that users have their own
processor.
Spooling and a file system can provide virtual card readers and virtual line printers.
A normal user time-sharing terminal serves as the virtual machine operator’s console.
Virtual Machines(cont)
Sem II-2011 3rd year G5-G81-68
The heart of the system, known as the virtual machine monitor, runs on the bare hardware and does the multiprogramming, providing not one, but several virtual machines to the next layer up.
However, unlike all other operating systems, these virtual machines are not extended machines, with files and other nice features.
Instead, they 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.
System Models
Sem II-2011 3rd year G5-G8
69
Non-virtual Machine Virtual Machine
VIRTUAL MACHINES(CONT)
Strengths/weakness of Virtual Machines
Sem II-2011 3rd year G5-G81-70
The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. • This isolation, however, permits no direct sharing
of resources. A virtual-machine system is a perfect vehicle for
operating-systems research and development.
• System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation.
The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine. (weakness)
IV.Microkernel System Structure
Sem II-2011 3rd year G5-G81-71
Microkernel is a small OS core that provides the foundation for modular extensions.
The main function of microkernel is to provide a communication facility between the client program and the various services that are also running in user space.
At the bottom layer, running in kernel mode, is a program called the Microkernel.
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.
Each user-level virtual machine can run its own operating system, except that each one is restricted to using only the resources it has asked for and been allocated.
.
Sem II-2011 3rd year G5-G81-72
The microkernel need only keep track of which virtual machine has been assigned which resource.
The microkernel architecture assigns only a few essential functions to the kernel, including address space, inter-process communication and basic scheduling.
The microkernel is designed to support execution of OS code which exists outside it. This feature permits new features and facilities to be
added to the OS to suit specific operating environments.
Benefits:I. easier to extend a microkernelII. easier to port the operating system to new architecturesIII.more reliable (less code is running in kernel mode)IV.more secure Detriments:
Performance overhead of user space to kernel space communication
MICROKERNEL SYSTEM STRUCTURE (CONT)
Sola
ris
Modula
r A
ppro
ach
Sem II-2011 3rd year G5-G81-73
Most modern operating systems implement kernel modulesUses object-oriented approachEach core component is separateEach talks to the others over known interfacesEach is loadable as needed within the kernel
Overall, similar to layers but with more flexible
V. MODULES SYSTEM STRUCTURE
Practice Exercises
Sem II-2011 3rd year G5-G81-74
What are the three main purposes of an operating system?
State the main advantage of multiprogramming?What are the main differences between operating
systems for mainframe computers and personal computers?
In a multiprogramming and time-sharing environment, several users share the system simultaneously. This situation can result in various security problems.a. What are two such problems?b. Can we ensure the same degree of security in a time-shared machine as we have in a dedicated machine? Explain your answer.
What are the differences between a trap and an interrupt? What is the use of each function?
Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for
instance, a cache as large as a disk), why not make it that large and eliminate the device?
Sem II-2011 3rd year G5-G81-75
What are the five major activities of an operating system in regard to process management?
States the functions of the OS in relation to resource management.
Describe the three major activities of an operating system in regard to memory management
What is the purpose of the command interpreter? Why is it usually separate from the kernel?
What is the purpose of system calls? Using system calls, write a program in either C or C++ that reads data from one file and copies it to another file.
PRACTICE EXERCISES(CONT)
END OF CHAPTER ONE
Sem II-2011 3rd year G5-G81-76
OPERATING SYSTEM AND ITS STRUCTURES