Chapter One
Overview of operating systems
Operating Systems and System Programming
(SEng3122)
Objectives
At the end of this session students will be able to:
➢ Understand the basic functions, concepts and principles of
operating systems.
➢ Understand the operating system services and concepts
➢ Explain about operating system structures and operations
➢ Understand about OS generations
➢ Computer system structure
➢ Understand system calls and their types
➢ Identify the different OS types:
2
Chapter one: overview of operating systems
Introduction
➢ Without its software, a computer is basically a useless lump of metal.
➢ With its software, a computer can store, process, and retrieve information;
play music and videos; send e-mail, search the Internet; and engage in
many other valuable activities to earn its keep.
➢ Computer software can be divided roughly into two kinds:
1. System software:- which manages the operation of the computer itself.
2. Application software:-which performs the actual work the user wants.
3
Contd.
➢ The most important system program (software) 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.
4
What is an operating system(OS)?
➢ A program that acts as an intermediary between a user of a
computer and the computer hardware.
➢ Is a program that controls the execution of application programs.
➢ It simply provides an environment with which other programs can
do useful work.
➢ OS performs basic tasks such as recognizing input from the
keyboard, keeping track of files and directories on the disk,
sending output to the display screen and controlling peripheral
devices.
5
Contd.
⚫ A more common definition is that the operating system is
the one program running at all times on the computer
(usually called the kernel), with Everything else is either
⚫ a system program (ships with the operating system) or
⚫ an application program
➢ The Operating System correspondingly includes
programs to manage these resources, such as a traffic
controller, a scheduler, memory management module, I/O
programs, and a file system.
6
Goal of operating system
➢ Operating system goals:
❖ Execute user programs and make solving user
problems easier.
❖ Make the computer system convenient to use.
❖ Use the computer hardware in an efficient manner.
7
Contd.
Figure 1-1 Users and applications depend on the OS to relate
to all applications and hardware components
8
Contd.
The OS must support the following tasks:
1. Providing the facility to create and modify program and data using
an editor.
2. Access to the compiler for translating the user program from
high-level language to machine language.
3. Providing a loader program to move the compiled program code
to the computer’s memory for execution.
4. Providing routines that handle the details of I/O programming.
9
Operating System as User Interface
⚫ Every general purpose computer consists of the
hardware, operating system, application programs and
users.
⚫ The fig. 1.2 shows the conceptual view of a computer
system component
10
Contd.
Fig 1.2 Abstract view of the components a computer systems
11
Contd.
1. Hardware - provides basic computing resources(CPU, memory ,I/O
devices).
2. Operating system - controls and coordinates the use of the hardware
among the various application programs for the various users.
3. Applications programs - define the ways in which the system
resources are used to solve the computing problems of the users
(compilers, database systems, video games, business pro grams).
4. Users (people, machines, other computers).
12
History of operating system
⚫ A major OS will evolve over time for a number of reasons:
✓ hardware upgrade
✓ New type of hardware
✓ New service
✓ fixes
⚫ Operating systems have been evolving through the years. The following
table shows the history of OS.
Generation Year Electronic devices used Types of OS
and devices
First 1945 – 55 Vacuum tubes Plug boards
Second 1955 – 1965 Transistors Batch system
Third 1965 – 1980 Integrated Circuit (IC) Multiprogramming
Fourth Since 1980 Large scale integration PC /time sharing
13
Contd.
➢ The 1940's - First Generations (Serial processing)
⚫ The earliest electronic digital computers had no operating systems.
⚫ Machines of the time were so primitive that programs were often entered one bit
at time on rows of mechanical switches (plug boards).
⚫ Programming languages were unknown (not even assembly languages).
⚫ Operating systems were unheard of.
➢ The 1950's - Second Generation (Simple batch system)
⚫ By the early 1950's, the routine had improved somewhat with the introduction
of punch cards. The General Motors Research Laboratories
implemented the first operating systems in early 1950's for their IBM 701.
⚫ The system of the 50's generally ran one job at a time.
14
Contd.
➢ The 1960's - Third Generation (Multiprogrammed batch system)
⚫ The systems of the 1960's were also batch processing systems, but
they were able to take better advantage of the computer's resources by
running several jobs at once.
➢ Fourth Generation (Time sharing systems)
⚫ With the development of LSI (Large Scale Integration) circuits, chips,
operating system entered in the personal computer and the workstation
age. Microprocessor technology evolved to the point that it becomes
possible to build desktop computers as powerful as the mainframes of
the 1970s.
15
Contd.
Figure 1.3 evolution of OS
16
Operating System Services (functions)
1. Managing Hardware :- OS interacts with hardware using drivers or BIOS.
2. Providing a user interface: the OS provides a GUI(graphical user
interface) so that users will be able to interact with the system easily.
3. Program execution:- OS loads a program into memory and executes
it.
4. I/O Operations:- since user programs cannot execute I/O operations
directly, the operating system must provide some means to perform I/O.
5. File-system manipulation:- program needs to read, write, create, and
delete files. The OS gives the permission to the program for operations
on file.
17
Contd.
6. Communications- exchange of information between
processes executing either on the same computer or on different
systems tied together by a network. Implemented via shared
memory or message passing.
7. Error detection:- ensure correct computing by detecting
errors in the CPU and memory hardware, in I/O devices, or in
user programs.
8. Running & managing applications: The OS installs and runs
all other PC software
❖ Applications rely on the OS for support operations
❖ Applications are typically tailored to a single OS
18
Contd.
➢ Operating system with multiple users provides the following
services:
1. Resource Allocation
2. Accounting
3. Protection
1) Resource Allocation :
⚫ If there are more than one user or jobs running at the same time,
then resources must be allocated to each of them.
19
contd.
⚫ Operating system manages different types of resources
require special allocation code, i.e. main memory, CPU
cycles and file storage. .
⚫ For allocating CPU, CPU scheduling algorithms are used
for better utilization of CPU.
⚫ CPU scheduling routines consider the speed of the CPU,
number of available registers and other required factors.
20
Contd.
2) Accounting :
⚫ Logs of each user must be kept.
⚫ It is also necessary to keep record of which user how much and what kinds
of computer resources. This log is used for accounting purposes.
⚫ The accounting data may be used for statistics or for the billing.
⚫ It also used to improve system efficiency.
3) Protection :
⚫ Protection involves ensuring that all access to system resources is
controlled.
⚫ Security starts with each user having to authenticate to the system, usually
by means of a password.
⚫ External I/O devices must be also protected from invalid access attempts.
⚫ In protection, all the access to the resources is controlled.
⚫ In multiprocess environment, it is possible that, one process to interface
with the other, or with the operating system, so protection is required.
21
Resource Allocation & Related Functions
of OS
➢ The resource allocation function performs binding of one or more resources with a
requesting program.
➢ It also deallocates resources from a program and allocates them to other
programs.
➢ There are two popular strategies for resource allocation:
A. Partitioning of resource:- the OS decides a priority what resources should be
allocated to user programs.
❖ This approach is called static allocation because the allocation is made
before the execution of the program begins.
❖ It is simple to implement but it suffers from a lack of flexibility.
❖ In this approach, there is a resource wastage because allocation is made on the
basis of perceived need of a program rather than its actual needs.
22
Contd.
B. Pool-Based Approach:- the OS maintains a common pool of
resources and allocates from this pool whenever a program requests a
resources.
❖ This approach is called dynamic allocation because the allocation
takes place during execution of a program.
❖ Dynamic allocation can lead to better utilization of resources
because resources are not wasted.
❖ In the partition resource allocation approach, the OS considers the
number of resources and the number of programs in the system
and decides how many resources of each kind would be allocated to
a program.
23
Contd.
➢ But in case of pool-based approach, OS consults the resource table (a
table which contains the name and address of a resource unit ad its
present status, i.e. whether it is free or allocated to some program)
when a program makes a request for a resource, allocates the resource
if it is free.
🞂 Resources can be shared by a set of programs in two ways:
▪ 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.
▪ Concurrent sharing:- two or more programs can concurrently use the
same resource.
✓ Data file like bus time tables are concurrently shared resources.
✓ But other resources are shared sequentially.
24
Resource Preemption.
❖ The OS can deallocate a resource when the program to which it is
allocated either terminates or makes an explicit request for
deallocation.
❖ 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.
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.
❖ 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.
25
Operating system components
➢ All OSs have similar core components
1. Shell
2. Kernel (core)
➢ The shell
❖ In computing, a shell is a user interface for access to an operating system’s
services
❖ exposes functions to users and applications
❖ Piece of software that provides an interface for users using either command-line
or graphical interface
❖ Acts as an interface between the user and the kernel.
❖ Normally reside on disks and are loaded into memory when needed.
26
Contd.
➢ The kernel (nucleus)
⚫ A kernel is the central part of an operating system.
⚫ It manages the operations of the computer and the hardware - most notably
memory and CPU time.
➢ There are two types of kernels:
⚫ A microkernel, which only contains basic functionality;
⚫ A monolithic kernel, which contains many device drivers.
❖ 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
❖ A computer user never interacts directly with the kernel. It runs behind
the scenes and cannot be seen, except for the text logs that it prints
27
Contd.
Figure 1-3 Inside an operating system, different components
perform various functions
28
Modes of operation
Dual mode operation
❖ In order to ensure the proper execution of the operating system, we must be able to
distinguish between the execution of operating-system code and user-defined code.
❖ The approach taken by most computer systems is to provide hardware support that
allows us to differentiate among various modes of execution.
❖ Two separate modes of operations are there namely:
1. User Mode
2. Kernel (supervisor or system or Privileged)mode
29
Operating System Structure
▪ 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 and
d. Microkernel’s
e. Modules 30
1. Monolithic Systems
➢ There is no well defined structure. That is, there is no structure.
➢ The operating system is written as a collection of procedures, each of
which can call any of the other ones whenever it needs.
➢ 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,
➢ 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).
➢ Different functionalities and services of monolithically structured OS
know and directly use addresses of each other’s data.
31
Contd.
▪ 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.
32
2. Layered Approach (Design)
➢ 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.
➢ 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.
➢ The OS is designed to organize the operating system as a hierarchy of layers, each one
constructed upon the one below it.
33
Contd.
layers functions
5 The operator
4 User programs
3 Input/output management
2 Operator-process communication
1 Memory and drum management
0 Processor allocation and multiprogramming
▪ Layer 0 dealt with allocation of the processor, switching between processes when
interrupts occurred or timers expired. In other words, layer 0 provided the basic
multiprogramming of the CPU.
▪ Layer 1 performs the memory management. It allocates the computer’s memory to satisfy
the memory requirements of programs and uses the drum (512 word) when it runs out of
memory.
▪ Layer 2 handled communication between each process and the operator console by
allocating a virtual console to each process.
▪ Layer 3 took care of managing the I/O devices and buffering the information stream
34s to
Contd.
➢ 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.
➢ The layered approach suffers from two problems:
1. The operation of a system be slowed down by the layered structure.
2. The second problem concerns difficulties in developing a layered design.
35
3. Virtual machine
➢ 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.
➢ 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.
36
Advantage/disadvantage of virtual machine
➢ 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. (Disadvantage)
37
4. Microkernel System Structure
➢ 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.
38
Contd.
➢ The microkernel need only keep track of which virtual machine has
been assigned which resource.
Figure 1.6 Architecture of a typical microkernel
39
Contd.
➢ 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.
o This feature permits new features and facilities to be added to the OS
to suit specific operating environments.
Benefits:
I. easier to extend a microkernel
II. easier to port the operating system to new architectures
III. more reliable (less code is running in kernel mode)
IV. more secure
40
[Link] structure
➢ Perhaps the best current methodology for operating-system design
involves using loadable kernel modules.
➢ Here, the kernel has a set of core components and links in additional
services via modules, either at boot time or during runtime.
➢ This type of design is common in modern implementations of UNIX, such
as Solaris, Linux, and Mac OS X, as well as Windows.
Figure 1.5 Solaris loadable modules
41
System call
➢ System calls provide the interface between a running program(Process) and the
operating system kernel.
❖ A system call instruction is an instruction that generates an interrupt that causes the OS
to gain control of the processor.
❖ A system call is used whenever a program needs to access a restricted source. Ex. A file
on hard disk, any hardware device.
❖ Most operations interacting with the system require permissions not available to a user
level process, or any form of communication with other processes requires the use of
system calls.
❖ Generally available as assembly-language instructions.
❖ Languages defined to replace assembly language for systems programming allow system
calls to be made directly (e.g., C, C++).
➢ Three general methods are used to pass parameters between a running program and
the operating system.
1. Pass parameters in registers.
2. Store the parameters in a table in memory, and the table address is passed as a
parameter in a register.
3. Push (store) the parameters onto the stack by the program, and pop off the stack by
operating system
42
Contd.
A System Call is the main way a user program interacts with the Operating System.
A system call is how a program requests a service from an OS's kernel. This may
include hardware related services (e.g. accessing the hard disk), creating and
executing new processes, and communicating with integral kernel services (like
scheduling). System calls provide an essential interface between a process and the
operating system.
43
System Call Types
▪ A system call is made using the system call machine language instruction.
▪ System calls can be roughly grouped into five major categories:
1. Process Management
• Load
• Execute
• Create process
• Terminate process
• Get/set process attributes
• Wait for time, wait for event, wait for signal
• Allocate, free Memory
2. Inter-Process Communication
I. create, delete communication connection
II. send, receive messages
[Link] status information
[Link] or detach remote devices
44
Contd.
3. File management
a. create file, delete file
b. open, close
c. read, write, reposition
d. get/set file attributes
5. I/O Device Management
i. request device, release device
ii. read, write, reposition
iii. get/set device attributes
iv. logically attach or detach devices
6. Information Maintenance
a. get/set time or date
b. get/set system data
c. get/set process, file, or device attributes
45
Types of operating system
➢ Within the broad family of operating systems, there are generally four types,
categorized based on the types of computers they control and the sort of applications
they support. The categories are
1. Real-time operating system(RTOS)
➢ Real-time operating systems are used to control machinery, scientific instruments and
industrial systems.
➢ An RTOS typically has very little user-interface capability, and no end-user utilities, since
the system will be a "sealed box" when delivered for use.
➢ A very important part of an RTOS is managing the resources of the computer so that a
particular operation executes in precisely the same amount of time, every time it occurs.
➢ In a complex machine, having a part move more quickly just because system resources are
available may be just as catastrophic as having it not move at all because the system is
46
Contd.
2. Single-user, single task
⚫ As the name implies, this operating system is designed
to manage the computer so that one user can
effectively do one thing at a time.
⚫ The Palm OS for Palm handheld computers is a good
example of a modern single-user, single-task operating
system.
47
Contd.
3. Single-user, multi-tasking
➢ This is the type of operating system most people use on their
desktop and laptop computers today.
➢ Microsoft's Windows and Apple's Mac OS platforms are both
examples of operating systems that will let a single user have
several programs in operation at the same time.
➢ For example, it's entirely possible for a Windows user to be
writing a note in a word processor while downloading a file
from the Internet while printing the text of an e-mail message.
48
Contd.
4. Multi-user, multi-tasking
➢ A multi-user operating system allows many different users to take
advantage of the computer's resources simultaneously.
➢ The operating system must make sure that the requirements of the
various users are balanced, and that each of the programs they are
using has sufficient and separate resources so that a problem with
one user doesn't affect the entire community of users.
➢ Unix, VMS (Virtual Memory System) and mainframe operating
systems, such as MVS (multiple virtual storage), are examples of
multi-user operating systems.
49
❑ exercise
1. Define Operating System?
2. Explain various operating system services?
3. Define operating system components?
4. List and briefly describe structures of operating
system ?
5. List and briefly describe types of operating systems?
50
Thank you!!!
51