You are on page 1of 49

Chapter 1

(Introduction to the Operating System)

Introduction to the Operating System: Introduction to Operating


Systems, Operating System Structure, Main Functions and characteristics
of Operating Systems, Types of Operating Systems, System calls, Types of
system calls, System programs.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Computer System Components


1. Hardware provides basic computing resources (CPU, Memory, I/O devices,
Communication).
2. Operating System controls and coordinates
use of the hardware among various application programs for various users.
3. System & Application Programs ways in which the system resources are used
to solve computing problems of the users (Word processors, Compilers, Web
browsers, Database systems, Video games).
4. Users (People, Machines, other computers).

A. Frank - P. Weisberg
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)

Static View of System


Components

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Dynamic View of System


Components

University Institute of Engineering (UIE)


Hierarchical view of computer system

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

What is OS?
Operating System is a software, which makes a computer to actually work.

It is the software the enables all the programs we use.

The OS organizes and controls the hardware.

OS acts as an interface between the application


programs and the machine hardware.

Examples: Windows, Linux, Unix and Mac OS, etc.

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

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

What is OS?

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Responsibilities of an Operating
System
There are three basic responsibilities (in literature):
1. Resource Manager manages and allocates resources.
2. Control program controls the execution of user programs and operations
of I/O devices.
3. Command Executer Provides an environment for running user
commands.
But one more modern view: the Operating System as a Virtual Machine.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Operating-System Structure
General-purpose OS is very large program
Various ways to structure ones
Simple structure MS-DOS
More complex -- UNIX
Layered an abstraction
Microkernel -Mach

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Simple Structure -- MS-DOS


MS-DOS written to provide the
most functionality in the least space
Not divided into modules
Limited in H/W functionality
MS-DOS was designed by few
people who had no idea & it
becomes so popular
Although MS-DOS has some
structure, its interfaces and levels of
functionality are not well separated

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Non Simple Structure -- UNIX


UNIX 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

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Non Simple Structure -- UNIX

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Layered Approach
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.
Main advantage of layered approach is
Modularity.
With modularity, layers are selected such
that each uses functions (operations) and
services of only lower-level layers.
The major difficulty with layered
approach is to divide the layers carefully,
because a layer can use only those layers
which are below it.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Microkernel System Structure


Moves as much from the kernel into user space
Mach example of microkernel
Mac OS X kernel (Darwin) partly based on Mach

Communication takes place between user modules using message passing


Benefits:
Easier to extend a microkernel
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
More secure

Detriments: Performance overhead of user space to kernel space communication

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Microkernel System Structure


Kernel is a computer program that manages I/O requests from software and
translates them into data processing instructions for CPU and other electronic
components of computer.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Functions of Operating System


1. Process Management
2. Main Memory Management
3. Secondary Storage Management
4. File Management
5. I/O Management
6. Protection & Security
7. Networking
8. Command Interpretation or Shell

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Process Management
A process is a program in execution. It is a unit of work within the
system. Program is a passive entity, process is an active entity.
Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data
Process termination requires reclaim of any reusable resources
Single-threaded process has one program counter specifying location
of next instruction to execute
Process executes instructions sequentially, one at a time, until
completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some operating system
running concurrently on one or more CPUs
Concurrency by multiplexing the CPUs among the processes /
threads

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Process Management Activities


The operating system is responsible for the following activities in connection with
process management:

Creating and deleting both user and system processes


Suspending and resuming processes
Providing mechanisms for process synchronization
Providing mechanisms for process communication
Providing mechanisms for deadlock handling

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Memory Management
To execute a program all (or part) of the instructions must be in memory
All (or part) of the data that is needed by the program must be in memory.
Memory management determines what is in memory and when
Optimizing CPU utilization and computer response to users

Memory management activities


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
Allocating and deallocating memory space as needed

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Storage Management
OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer
rate, access method (sequential or random)

File-System management
Files usually organized into directories
Access control on most systems to determine who can access what
OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

File-System Management
File-System management
Files usually organized into directories
Access control on most systems to determine who can access what
OS activities include
Creating and deleting files and directories
Primitives to manipulate files and directories
Mapping files onto secondary storage
Backup files onto stable (non-volatile) storage media

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

I/O Subsystem
One purpose of OS is to hide peculiarities of hardware devices from the user
I/O subsystem responsible for
Memory management of I/O including buffering (storing data temporarily
while it is being transferred), caching (storing parts of data in faster
storage for performance), spooling (the overlapping of output of one job
with input of other jobs)
General device-driver interface
Drivers for specific hardware devices

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Protection and Security


Protection any mechanism for controlling access of processes or users to
resources defined by the OS
Security defense of the system against internal and external attacks
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 also associated with each process, file
Privilege escalation allows user to change to effective ID with more
rights

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

OS challenges
Reliability
Does the system do what it was designed to do?
Availability
What portion of the time is the system working?
Mean Time To Failure (MTTF), Mean Time to Repair
Security
Can the system be compromised by an attacker?
Privacy
Data is accessible only to authorized users

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

OS challenges
Performance
Latency/response time
How long does an operation take to complete?
Throughput
How many operations can be done per unit of time?
Overhead
How much extra work is done by the OS? Fairness
How equal is the performance received by different users?
Predictability
How consistent is the performance over time?
Portability
For programs:
Application programming interface (API)
For the kernel
Hardware abstraction layer

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Batch operating system

In early days, computer work was given on punch cards and then these punch cards
behave as input to the computer.

These jobs or batch jobs were then executed by the computer one by one. So that
computers were called as batch computers or batch systems.

The work done by batch systems are in parts i.e. one job is processed then another
job in the queue is processed and so on.

The various jobs of the users are collected in a queue. This process is known as
Spooling (Simultaneous Peripheral Operations On Line).

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Memory Layout for a Simple


Batch System

OS

User
Program
Area

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Batch Processing system

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Batch operating system


Advantages -
Repeated jobs are done fast in batch systems without user interaction.
You dont need special hardware and system support to input data in batch systems.
Best for large organizations but small organizations can also benefit from it.
Batch systems can work offline so it makes less stress on processor.

Disadvantages -
Lack of interaction between the user and job.
CPU is often idle, because the speeds of the mechanical I/O devices is slower than
CPU.
Difficult to provide the desired priority.

Examples Payroll systems, Bank statementsetc.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Multiprogrammed Systems
This allows to execute multiple programs.

In this, several processes are kept in memory (set of jobs are kept in Job Pool) & CPU
execute all these processes concurrently.

When one process start performing I/O operations , the CPU is allocated to another user
process in the main memory that is ready to use the CPU.

Multiprogramming increases CPU utilization by organizing jobs so that the CPU


always has one to execute.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Memory layout for a


multiprogramming system.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Multiprogrammed Systems
Advantages
It increases CPU utilization.
It increases throughput also by utilizing idle time of CPU for running other
programs that are already present in main memory.
It lowers the Response time by recognizing the priority of a job as it enters the
system & by processing jobs on a priority basis.
Disadvantages -
It is fairly sophisticated and more complex.
A multiprogramming operating system must keep track of all kinds of jobs it is
concurrently running.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Multitasking and Time-sharing


operating systems
Time-sharing or Multitasking is a logical extension of
multiprogramming.
Processor's time which is shared among multiple users simultaneously is termed as time-
sharing.
It refers to term where multiple jobs are executed by the CPU simultaneously by
switching between them.
A time sharing operating system is that in which each task is given some time to execute
and all tasks are given time so that all processes run seamlessly without any problem.
Suppose there are many users attached to a single system then each user has given time
of CPU.
No user can feel to have trouble in using the system

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Multitasking and
Time-sharing operating systems

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Multitasking and Time-sharing


operating systems
Advantages
Provide advantage of quick response.
Reduces CPU idle time.

Disadvantages -
Problem of reliability.
Security and Integrity of user programs and data is at risk.
It consumes much resources so it need special operating systems.
Switching between tasks becomes sometimes sophisticated as there are lot of users and
applications running which may hang up the system. So the time sharing systems
should have high specifications of hardware.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Multiprocessing systems
Multiprocessing is the use of two or more central processing units (CPUs)
within a single computer system.
The term also refers to the ability of a system to support more than one
processor and/or the ability to allocate tasks between them.

Advantage -
1.Increased throughput
2.Economy of scale
3. Increased reliability

Disadvantage -
1) If one processor fails then it will affect in the speed
2) Multiprocessor systems are expensive
3) Large main memory required.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Types of Multiprocessor systems


Symmetric Multiprocessor (SMP)
In this, each CPU runs an identical copy of OS and can communicate as needed.

Asymmetric Multiprocessor (ASMP)


In this, each processor assigned a specific task. This model is called master-slave
since one CPU is the master and all the others are slaves.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Distributed systems
Distributed systems use multiple central processors to serve multiple real time
application and multiple users.

Data processing jobs are distributed among the processors accordingly to which
one can perform each job most efficiently.

The processors communicate with one another through various communication


lines (such as high-speed buses or telephone lines). These are referred as loosely
coupled systems or distributed systems.

Processors in a distributed system may vary in size and function. These processors
are referred as sites, nodes, computers and so on.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Model of Distributed Systems

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Distributed systems
Advantages
Speedup the exchange of data with one another via electronic mail.
Reduction of the load on the host computer.
Reliability (fault tolerance) - if some of the machines crash, the system can survive.
Sharing of data/resources - shared data is essential to many applications (banking,
computer- supported cooperative work, reservation systems); other resources can be
also shared (e.g. expensive printers).

Disadvantages
Complex System - Distributed systems are much more complex to setup and
difficult to maintain.
Security problems - sharing generates the problem of data security.
Networking problems: several problems are created by the network infrastructure,
which have to be dealt with: loss of messages, overloading, ...

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Real Time Systems


A real time operating system is the type of system which uses maximum time and
resources to output exact and on the time result.

There is no difference between the results when same problem run on different
occasion on same machine.

Real System is always on line whereas on line system need not be real time.

Real-time systems are used when there are rigid time requirements on the operation
of a processor or the flow of data and real-time systems can be used as a control
device in a dedicated application.

Real-time operating system has well-defined, fixed time constraints otherwise system
will fail. For example Scientific experiments, medical imaging systems, industrial
control systems, weapon systems, robots, and home-applicance controllers, Air traffic
control system etc.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Types of real-time operating


systems
Hard real-time systems -
Hard real-time systems guarantee that critical tasks complete on time. For Ex. Scientific
experiments, medical imaging systems, industrial control systems, weapon systems,
robots, and home-applicance controllers, Air traffic control system etc.

Soft real-time systems -


Soft real time systems are less restrictive. Critical real-time task gets priority over other
tasks and retains the priority until it completes. Soft real-time systems have limited
utility than hard real-time systems.For example, Multimedia, virtual reality, Advanced
Scientific Projects like undersea exploration and planetary rovers etc.

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Real-time operating systems


Advantages -
Focus on Application - These type of operating system focus on applications
which are running and usually give less importance to other application residing in
waiting stage of life cycle. So less applications or tasks are managed and give exact
result on current execution work.
Error Free - RTOS (Real Time Operating System) is error free that mean it has no
chances of error in performing tasks.
24-7 systems: RTOS can be best used for any applications which run 24 hours
and 7 days because it do less task shifting and give maximum output.
Memory Allocation: - Memory allocation is best managed in these type of
systems.
Disadvantages
Expensive: - RTOS are usually very expensive because of the resources they need
to work.
Not easy to program: - The designer have to write proficient program for real time
operating system which is not easy as a piece of cake.
Low Priority Tasks: - The low priority tasks may not get time to run because these
systems have to keep accuracy of current running programs

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

System Calls
Programming interface to the services provided by the OS
Typically written in a high-level language (C or C++)
Mostly accessed by programs via a high-level Application Programming
Interface (API) rather than direct system call use
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)

Note that the system-call names used throughout this text are generic

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

System Call Implementation


Typically, a number associated with each system call
System-call interface maintains a table indexed according to these
numbers
The system call interface invokes the 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 implemented
Just needs to obey API and understand what OS will do as a result
call
Most details of OS interface hidden from programmer by API
Managed by run-time support library (set of functions built into
libraries included with compiler)

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Types of System Calls


Process control
create process, terminate process
end, abort
load, execute
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
Dump memory if error
Debugger for determining bugs, single step execution
Locks for managing access to shared data between processes

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Types of System Calls


File management
create file, delete file
open, close file
read, write, reposition
get and set file attributes
Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
Protection
Control access to resources
Get and set permissions
Allow and deny user access

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

Types of System Calls (Cont.)


Information maintenance
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
Communications
create, delete communication connection
send, receive messages if message passing model to host name or
process name
From client to server
Shared-memory model create and gain access to memory regions
transfer status information
attach and detach remote devices

University Institute of Engineering (UIE)


Department of Computer Science and Engineering (CSE)

References

Operating System Concepts 9th Edition, Silberschatz, Galvin and Gagne


2013

University Institute of Engineering (UIE)

You might also like