Chapter 1 Introduction
Chapter 1 Introduction
Chapter 1 Introduction
1
Objective
At the end of this session students will be able to:
Understand the basic functions, concepts and principles of operating systems.
2
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:
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
computer hardware.
Is a program that controls the execution of application programs.
It controls and coordinates use of hardware among various applications and users.
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.
Operating system goals:
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.
Operating system is the first layer of software loaded in to the computer working memory.
It is a program that acts as an interface between the user, the computer software and
the hardware resources.
It provides a software platform on top of which other program can run
“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.
6
Operating System Functions
I. Managing Hardware :- OS interacts with hardware using drivers or BIOS.
II. Providing a user interface: the OS provides a GUI(graphical user interface) so that users will
be able to interact with the system easily.
III. Managing files: it OS manages and controls the files and folders created.
IV. 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
V. Security Management
VI. Coordination of communication on the network
on and
the
r dw al l
are
mp tio re epen ers
ha o
on ns late d
d Us
t
tio 1-1
ts and
ns
ap ure
OS plica
co plica o
en
t
Fig
ap
7
OS Components
All OSs have similar core components, as highlighted in Fig. 1.2:
1. Shell
2. Kernel (core)
Piece of software that provides an interface for users using either command-
Normally reside on disks and are loaded into memory when needed.
Allocates time & memory to programs and handles the file store &
9
Common tasks performed by OS
3. Maintain current status of all users currently using the system (They are
4. Maintain current status of all programs being executed by active users and
5. Maintain current status of all resources in the system and allocate resources
10
Computer System Components
Hardware:- provides basic computing
requesting program.
It also deallocates resources from a program and allocates them to other programs.
12
Contd.
B. Pool-Based Approach:- the OS maintains a common pool of resources and
14
Resource Preemption.
The OS can deallocate a resource when the program to which it is
15
manner.
Hardware Resources
Processor: execute instructions
representations
16
Resource Management Functions
17
Types of multiplexing
1. Time multiplexing
time-sharing
scheduling a serially-
reusable resource
among several users
2. Space multiplexing
space-sharing
dividing a multiple-
use resource up
among several users
18
Time-multiplexing I/O devices
19
Examples of where you will find OSs
1. Servers (Mainframe Computers):- specialized for processing
large volumes of requests for a given service.
Generally has a large number of necessary resources.
web server, file server, print server, time-sharing systems for
interactive use, database management systems.
Reduce setup time by batching similar jobs
Automatic job sequencing – automatically transfers control from
one job to another. First rudimentary operating system.
Resident monitor
Initial control in monitor
Control transfers to job
When job completes control transfers pack to monitor
20
Contd.
2. Desktops:- specialized for single-user (or limited number of users).
Generally has a GUI that is integral to system software
Designed to minimize response time to user requests
User convenience and responsiveness.
Can adopt technology developed for larger operating system’ often
individuals have sole use of computer and do not need advanced
CPU utilization of protection features.
May run several different types of operating systems (Windows,
MacOS, UNIX, Linux), which will be implemented in Lab 1 &2.
&2
21
Contd.
3. Embedded Systems:- specialized for managing a limited number of
resources such as power, memory, I/O speed.
Examples of Embedded Systems: PDAs, cell phones, smart cards,
automobiles.
Issues:
Limited memory
Slow processors
Small display screens.
22
Contd.
Clustering can be:
Asymmetric clustering: one server runs the application while other
servers standby.
Symmetric clustering: all N hosts are running the application.
1. Hard real-time:- Secondary storage limited or absent, data stored in short term
system features.
24
Contd.
6. Distributed Systems:- Distribute the computation among several physical processors.
Distributed OS runs on and controls the resources of multiple machines.
DOS owns the whole network and makes it look like a virtual uniprocessor or may be virtual
multiprocessor.
Loosely coupled system – each processor has its own local memory, processors communicate
with one another through various communications lines, such as high-speed buses or
telephone lines.
lines
Advantages of distributed systems.
Resources Sharing
Reliability
Communications
25
Contd.
Requires networking infrastructure.
Increased throughput
Economical
Increased reliability
graceful degradation
fail-soft systems
27
Contd.
B.Asymmetric multiprocessing
It increases CPU utilization by organizing jobs so that the CPU always
29
OS Features Needed for Multiprogramming
I/O routine supplied by the system.
Memory management – the system must allocate the memory to several jobs.
CPU scheduling – the system must choose among several jobs ready to run.
Allocation of devices.
operating system finishes the execution of one command, it seeks the next “control
statement” from the user’s keyboard.
On-line system must be available for users to access data and code.
31
Operating-System Operations
Modern OS are Interrupt-driven by hardware.
If there are no processes to execute, no I/0 devices to service, and no users to whom
to respond, an operating system will sit quietly waiting for something to happen.
Events are almost always signaled by the occurrence of an interrupt or a trap
A trap (or an Exception) is a software-generated interrupt caused either by an error(for
division by zero or invalid memory access) or by a specific request from a user program
that an operating-system service be performed.
Other process problems include infinite loop, processes modifying each other or the
operating system.
The interrupt-driven nature of an operating system defines that system's general
structure
A properly designed operating system must ensure that an incorrect (or malicious)
32
Dual-Mode Operation
In order to ensure the proper execution of the operating system, we must be able to
A bit, called the mode bit is added to the hardware of the computer to indicate the
behalf of the operating system and one that is executed on behalf of the user.
System call changes mode to kernel, return from call resets it to user
33
Transition from User to Kernel Mode
When the computer system is executing on behalf of a user application, the system
is in user mode. However, when a user application requests a service from the
operating system (via a system call), it must transition from user mode to kernel
mode to fulfill the request.
34
The system always switches to user mode before passing control to a user program.
Contd.
The dual mode of operation provides us with the means for protecting the OS from errant
users-and errant users from one another by designing some of the machine instructions as
privileged instructions.
The hardware allowed privileged instructions to be executed only in kernel mode.
If an attempt is made to execute a privileged instruction in user mode, the hardware does not execute the
instruction but rather treats it as illegal and traps it to the operating system.
The instruction to switch to kernel mode, I/0 control timer management and interrupt
management are examples of privileged instructions.
35
Contd.
We must ensure that the OS maintains a control over the CPU. i.e. we can not allow a user
program to get stuck in an infinite loop or to fail to call system services and never return
control to the OS.
To accomplish this goal we must use a timer that can be set to interrupt the computer after
specific period.
How it works?
The OS sets the counter
Every time the clock ticks, the counter is decremented
When the counter reaches zero generate an interrupt
Set up before scheduling process to regain control or terminate program that exceeds
allotted time.
36
Process Management
A process is a program in execution. It is a unit of work within the system.
Initialization data
Single-threaded process has one program counter specifying location of next instruction to execute
Typically system has many processes, some user, some operating system running concurrently
37
Process Management Activities
38
Memory Management
All data in memory before and after processing
Keeping track of which parts of memory are currently being used and by whom
Deciding which processes (or parts thereof) and data to move into and out of
memory.
39
Storage Management
OS provides uniform, logical view of information storage
Varying properties include access speed, capacity, data-transfer rate, access method
(sequential or random)
File-System management
OS activities include
Entire speed of computer operation hinges on disk subsystem and its algorithms
OS activities
Free-space management
Storage allocation
Disk scheduling
performance), spooling (the overlapping of output of one job with input of other
jobs)
42
Protection and Security
Protection – any mechanism for controlling access of processes or users to resources defined
by the OS.
Huge range, including denial-of-service, worms, viruses, identity theft, theft of service
Systems generally first distinguish among users, to determine who can do what
User identities (user IDs, security IDs) include name and associated number, one per user
User ID then associated with all files, processes of that user to determine access control
Group identifier (group ID) allows set of users to be defined and controls managed, then
43
Operating System Services
1. User Interface:- Almost all operating systems have a User Interface.
This interface can take several forms:- Command Line Interface (CLI). Batch Interface, in
which commands and directives to control those commands are entered into files,
and those files are executed, and Graphical User Interface (GUI)
2. Program execution:- OS loads a program into memory and executes the it.
3. I/O Operations:- since user programs cannot execute I/O operations directly, the
operating system must provide some means to perform I/O.
4. File-system manipulation:- program needs to read, write, create, and delete files.
6. Error detection:- ensure correct computing by detecting errors in the CPU and
44 memory hardware, in I/O devices, or in user programs.
System Calls
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
45
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.
46
System Call Types
A system call is made using the system call machine language instruction.
These components of modern systems are interconnected and melded to the kernel.
a. monolithic systems
b. layered systems
d. Microkernel’s
e. Modules
48
I. Monolithic Systems
By far the most common organization, this approach might well be subtitled "The Big Mess."
The operating system is written as a collection of procedures, each of which can call any of the
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
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
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
50
MS-DOS Layer Structure
51
II. Layered Approach(Design)
Were developed in which functions are organized hierarchically and interaction only takes
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
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
ite yer
re
ctu
ch La
Ar S
O
54
III. Virtual Machines
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.
The operating system creates the illusion of multiple processes, each executing on its own
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.
55
Contd.
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.
Different virtual machines can, and frequently do, run different operating systems.
VMware and Microsoft's Virtual PC are marketed for such installations. Such systems are
also useful in education. For instance, students working on Windows can work Linux OS
as using VMware host with no risk of damaging other software installed on the same PC.
Another are a where virtual machines are used, but in a somewhat different way, is for
running Java programs (Using JVM).
The Java compiler produces code for JVM, which then typically is executed by a
software JVM interpreter.
56
System Models
57
Advantages/Disadvantages of Virtual Machines
58
IV. 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.
59
Contd.
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 microkernel
II. easier to port the operating system to new architectures
III.more reliable (less code is running in kernel mode)
IV.more secure
60
System Design Goals
61
System Implementation
62
System Generation (SYSGEN)
63
Computing Environments
Traditional computer
Blurring over time
Office environment
PCs connected to a network, terminals attached to
mainframe or minicomputers providing batch and
timesharing
Now portals allowing networked and remote systems
access to same resources
Home networks
Used to be single system, then modems
Now firewalled, networked
64
Contd.
Client-Server Computing
Dumb terminals supplanted by smart PCs
Many systems now servers, responding to requests generated
by clients
Compute-server provides an interface to client to request
services (i.e. database)
File-server provides interface for clients to store and retrieve
files
65
Peer-to-Peer Computing
Another model of distributed system
66
Web-Based Computing
into Linux and Windows XP, which can be clients and servers
67
Do we need an OS?
Not always
Reusable functions
68