Operating System Structure
Ch # 2
• An operating system provides the environment
within which programs are executed
Multiprogramming:
• One of the most important aspects of operating
systems is the ability to multiprogram.
• A single program cannot, in general, keep either
the CPU or the I/O devices busy at all times.
Single users frequently have multiple programs
running
• Multiprogramming increases CPU utilization by organizing jobs
(code and data) so that the CPU always has one to execute.
Time sharing
• Time sharing (or multitasking) is a logical extension of
multiprogramming.
• In time-sharing systems, the CPU executes multiple jobs by
switching among them, but the switches occur so frequently
that the users can interact with each program while it is
running.
• Time sharing requires an interactive computer system, which
provides direct communication between the user and the
system.
• The operating system can be implemented with the help of
various structures.
• The structure of the OS depends mainly on how the various
standard components of the operating system are
interconnected and combined into the kernel.
Operating System Structures
We have the following structures in the operating system
• Simple Structure
• Monolithic Structure
• Micro-Kernel Structure
• Hybrid-Kernel Structure
• Layered Structure
• Modular Structure
• Virtual Machines
Simple structure
• Such operating systems do not have well-defined structures
and are small, simple, and limited.
• The interfaces and levels of functionality are not well
separated.
• MS-DOS is an example of such an operating system.
• In MS-DOS, application programs are able to access the basic
I/O routines.
• These types of operating systems cause the entire system to
crash if one of the user programs fails.
Advantages of Simple Structure
• It is easy for kernel developers to develop such an operating
system.
• Disadvantages:
• The structure is very complicated, as no clear boundaries exist
between modules.
• Inefficient.
Monolithic Structure
• Followed by earlier Unix Operating System.
• Everything is packed into one level hence we call it a
Monolithic structure.
• Everything below the system-call interface and above the
physical hardware is the kernel.
• They are difficult to implement and extend.
Layered structure
• An OS can be broken into pieces and retain much more control
over the system.
• In this structure, the OS is broken into a number of layers
(levels).
• The bottom layer (layer 0) is the hardware, and the topmost
layer (layer N) is the user interface.
• These layers are so designed that each layer uses the functions
of the lower-level layers.
• This simplifies the debugging process, if lower-level layers are
debugged and an error occurs during debugging, then the
error must be on that layer only, as the lower-level layers have
already been debugged.
Advantages of Layered structure
• Layering makes it easier to enhance the operating system, as
the implementation of a layer can be changed easily without
affecting the other layers.
• It is very easy to perform debugging.
Disadvantages of Layered structure
• It requires careful planning for designing the layers, as the
higher layers use the functionalities of only the lower layers.
• May not be efficient, the time by the services provided is not
very fast.
Micro-kernel Structure
• This structure designs the operating system by removing all
non-essential components from the kernel and implementing
them as system and user programs.
• This results in a smaller kernel called the micro-kernel.
• Advantages of this structure are that all new services need to
be added to user space and does not require the kernel to be
modified.
• Thus it is more secure and reliable as if a service fails, then rest
of the operating system remains untouched.
• Mac OS is an example of this type of OS.
Advantages of Micro-kernel structure
• Simplicity, core kernal is very small
• As microkernels are small so these can be tested effectively.
• Disadvantages of Micro-kernel structure
• Increased level of inter module communication degrades
system performance.
Hybrid-Kernel Structure
• Hybrid-kernel structure is nothing but just a combination of
both monolithic-kernel structure and micro-kernel structure.
• Basically, it combines properties of both monolithic and micro-
kernel and make a more advance and helpful approach.
Advantages of Hybrid-Kernel Structure
• It offers good performance as it implements the advantages of
both structure in it.
• It supports a wide range of hardware and applications.
• It provides better isolation and security by implementing
micro-kernel approach.
• It enhances overall system reliability by separating critical
functions into micro-kernel for debugging and maintenance.
Disadvantages of Hybrid-Kernel Structure
• It increases overall complexity of system by implementing both
structure (monolithic and micro) and making the system
difficult to understand.
• The layer of communication between micro-kernel and other
component increases time complexity and decreases
performance compared to monolithic kernel.
Modular structure or approach
• It is considered as the best approach for an OS.
• It involves designing of a modular kernel.
• The kernel has only a set of core components and other
services are added as dynamically loadable modules to the
kernel either during runtime or boot time.
• It resembles layered structure due to the fact that each kernel
has defined and protected interfaces, but it is more flexible
than a layered structure as a module can call any other
module.
VMs (virtual machines)
• Based on our needs, a virtual machine abstracts the hardware
of our personal computer, including the CPU, disc drives, RAM,
and into a variety of different execution contexts, giving us the
impression that each execution environment is a different
computer.
• An illustration of it is a virtual box.
• Softwares like Vmware or Virtual box allows
you to install the virtual machine in your
system, to install the operating systems.
OS Services
• An Operating System provides services to both the users and to
the programs.
• It provides programs an environment to execute.
• It provides users the services to execute the programs in a
convenient manner.
Following are a few common services provided by
an operating system.
• Program execution
• I/O operations
• File System manipulation
• Communication
• Error Detection
• Resource Allocation
• Protection
Program execution
• Operating systems handle many kinds of activities from user
programs to system programs like printer service, name
servers, etc. Each of these activities is encapsulated as a
process.
• A process includes the complete execution context (code to
execute, data to manipulate, registers, OS resources in use).
Major Activities of OS w.r.t Program Management
• Loads a program into memory.
• Executes the program.
• Handles program's execution.
• Provides a mechanism for process synchronization.
• Provides a mechanism for process communication.
• Provides a mechanism for deadlock handling.
I/O Operation
• An I/O subsystem comprises of I/O devices and their
corresponding driver software. Drivers hide the peculiarities of
specific hardware devices from the users.
• An Operating System manages the communication between
user and device drivers.
• I/O operation means read or write operation with any file or
any specific I/O device.
• Operating system provides the access to the required I/O
device when required.
File system manipulation
• A file represents a collection of related information. Computers
can store files on the disk (secondary storage), for long-term
storage purpose.
• Examples of storage media include magnetic tape, magnetic
disk and optical disk drives like CD, DVD.
• Each of these media has its own properties like speed, capacity,
data transfer rate and data access methods.
• A file system is normally organized into directories for easy
navigation and usage.
• These directories may contain files and other directions.
Major Activities of OS w.r.t File Management
• Program needs to read or write a file.
• The operating system gives the permission to
the program for operation on file.
• Permission varies from read-only, read-write,
denied and so on.
• Operating System provides an interface to the
user to create/delete files or directories.
• Operating System provides an interface to
create the backup of file system.
Communication
• In case of distributed systems which are a collection of
processors that do not share memory, peripheral devices, the
operating system manages communications between all the
processes.
• Multiple processes communicate with one another through
communication lines in the network.
Major Activities of OS w.r.t communication
• Two processes often require data to be transferred between
them
• Both the processes can be on one computer or on different
computers, but are connected through a computer network.
• Communication may be implemented by two methods, either
by Shared Memory or by Message Passing.
Error handling
Errors can occur anytime and anywhere. An error may occur in:
• CPU
• I/O devices
• Memory and hardware.
Major Activities of OS w.r.t Error Handling
• The OS constantly checks for possible errors.
• The OS takes an appropriate action to ensure correct and
consistent computing.
Resource Management
• In case of multi-user or multi-tasking environment, resources
such as main memory, CPU cycles and files storage are to be
allocated to each user or job.
• Following are the major activities of an operating system with
respect to resource management;
– The OS manages all kinds of resources using schedulers.
– CPU scheduling algorithms are used for better utilization of CPU.
Protection
• Considering a computer system having multiple users and
concurrent execution of multiple processes, the various
processes must be protected from each other's activities.
• Protection refers to a mechanism or a way to control the
access of programs, processes, or users to the resources
defined by a computer system.
Memory Management
• Let’s understand memory management by OS in simple way.
Imagine a cricket team with limited number of player .
• The team manager (OS) decide whether the upcoming player
will be in playing 11 ,playing 15 or will not be included in team
, based on his performance .
• In the same way, OS first check whether the
upcoming program fulfill all requirement to
get memory space or not ,if all things good, it
checks how much memory space will be
sufficient for program and then load the
program into memory at certain location.
• And thus, it prevents program from using
unnecessary memory.
Process Management
• Process management refers to the activities involved in
managing the execution of multiple processes in an operating
system.
• It includes creating, scheduling, and terminating processes, as
well as allocating system resources such as CPU time, memory,
and I/O devices.
Networking
• This service enables communication between devices on a
network, such as connecting to the internet, sending and
receiving data packets, and managing network connections.
Time Management
• Imagine traffic light as (OS), which indicates all the
cars(programs) whether it should be stop(red)=>(simple
queue) , start(yellow)=>(ready-queue), move(green)=>(under
execution) and this light (control) changes after a certain
interval of time at each side of the road(computer system) so
that the cars(program) from all side of road move smoothly
without traffic.
User Interfaces
• The user and operating system are connected with each other
with the help of interface, so interface is used to connect the
user and OS.
• In computers there are different interfaces.
• So, different types of tasks can be performed by the help of
different interfaces.
• User interface is essential, and all operating
systems provide it.
• Users either interface with the operating
system through the command-line interface
or graphical user interface (GUI).
• The command interpreter executes the next
user-specified command.
• A GUI offers the user a mouse-based window
and menu system as an interface.
Graphical user interface
• The graphical user interface is used for playing games, watching
videos, etc.
• These are done with the help of GUI because all these applications
require graphics.
• The GUI is one of the necessary interfaces because only by using
the user can clearly see the picture, play videos.
• So, we need GUI for computers, and this can be done only with the
help of an operating system.
• When a task is performed in the computer then the OS checks the
task and defines the interface which is necessary for the task. So,
we need GUI in the OS.
The basic components of GUIs are;
• Start menu with program groups
• Taskbar which showing running programs
• Desktop screen
• Different icons and shortcuts.
Command line interface
• The command-line interface is an interface
whenever the user needs to have different
commands regarding the input and output
and then a task is performed so this is called
the command-line argument and it is used to
execute the output and create, delete, print,
copy, paste, etc.
Command Interpreter
• SHELL is a program which provides the interface between the
user and an operating system.
• Kernel controls all essential computer operations, and provides
the restriction to hardware access, coordinates all executing
utilities, and manages Resources between process.
• Using kernel only user can access utilities provided by
operating system.
• The main function of the command
interpreter is to get and execute the next user-
specified command.
o C-Shell
o Bourne Shell
o Korn Shell
o Bash (Bourne again Shell)
Advantages
• Less overhead
• Faster management
• Efficient Resource Use
• Command Line Interface.
Disadvantages
• The steeper learning curve is associated with memorizing
commands and a complex syntax.
• Different commands are used in different shells
System programs
System programs, also known as system utilities, provide a
convenient environment for program development and
execution.
• File management. These programs create, delete, copy,
rename, print, list, and generally manipulate files and
directories
• Status information. Some programs simply ask the system for
the date, time, amount of available memory or disk space, etc.
• File modification. Several text editors may be
available to create and
modify the content of files stored on disk or
other storage devices.
• Programming-language support. Compilers,
assemblers, debuggers, etc for common
programming languages are often provided
with the operating system or available as a
separate download
• Program loading and execution. Once a
program is assembled or compiled, it must be
loaded into memory to be executed.
• Communications. These programs provide the
mechanism for creating virtual connections
among processes, users, and computer
systems