OS - Module 1
OS - Module 1
Introduction to
Operating Systems
Module 1:
Operating Systems 2
What is Operating
System ?
• An operating system is a program that manages a
computer’s hardware. It also provides a basis for
application programs and acts as an intermediary
between the computer user and the computer hardware.
• Operating system goals:
• A program that controls the execution of application
programs
• Make the computer system convenient to use.
• Use the computer hardware in an efficient manner.
Operating Systems 3
Where does the OS fit in?
• Basic Taxonomy HW SW
Applications System
OS Non-OS
• Software is differentiated according to its purpose
• System software provides a general environment where
programmers/developers can create applications and
users can run applications
Operating Systems 4
Introduction
• A computer system consists
of
• hardware
• system programs
• application programs
Operating Systems 5
System Goals
• Objectives of OS
• Convenience
• An operating system makes a computer more
convenient to use.
• Efficiency
• An operating system allows the computer system
resources to be used in an efficient manner.
• Ability to Evolve
• Should permit effective development, testing, and
introduction of new system features and functions
without interfering with service.
Operating Systems 6
Two View points
• User view
• User sits in front of PC
• User sit at a terminal connected to a mainframe
• System view
• Resource allocator
• Control program
Operating Systems 7
Abstract view of a
computer system
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 programs).
4. Users (people, machines, other computers).
Operating Systems 8
Abstract View of System Components
Operating Systems 9
Operating System
Definitions
• Resource allocator – manages and allocates
resources.
• Control program – controls the execution of user
programs and operations of I/O devices .
• Kernel – the one program running at all times (all else
being application programs).
Operating Systems 10
Operating System as a
resource manager
• It is actually a program that is executed by the
processor to control the processor!
• Directs the processor in the use of system resources
• Directs the processor when executing other
programs
• Processor stops executing the operating system in
order to execute other programs and, then, gives the
control back to the operating system
Operating Systems 11
Operating System as a
resource manager
• Memory management is decided by the operating
system and memory management hardware in the
processor.
• The operating system decides about the access of
programs and files to I/O devices.
• In case of multiple processors, it decides for them
all
Operating Systems 12
Operating system
timeline
• First generation: 1945 – 1955
• Vacuum tubes
• Plug boards
• Second generation: 1955 – 1965
• Transistors
• Batch systems
• Third generation: 1965 – 1980
• Integrated circuits
• Multiprogramming
• Fourth generation: 1980 – present
• Large scale integration
• Personal computers
• Next generation: ???
• Systems connected by high-speed networks?
• Wide area resource management?
Operating Systems 13
First generation: direct
input
• Run one job at a time
• Enter it into the computer (might require
rewiring!)
• Run it
• Record the results
• Problem: lots of wasted computer time!
• Computer was idle during first and last steps
• Computers were very expensive!
• Goal: make better use of an expensive commodity:
computer time
Operating Systems 14
Second generation: batch
systems
Operating Systems 15
• Advantages of batch systems
• move much of the work of the operator to the computer
• increased performance since it was possible for job to
start as soon as the previous job finished
• Disadvantages
• turn-around time can be large from user standpoint
• more difficult to debug program
• due to lack of protection scheme, one batch job can
affect pending jobs (read too many cards, etc)
• a job could corrupt the monitor, thus affecting pending
jobs
• a job could enter an infinite loop
Operating Systems 16
Spooling
• Original batch systems used tape drives
• Later batch systems used disks for buffering
• Operator read cards onto disk attached to the computer
• Computer read jobs from disk
• Computer wrote job results to disk
• Operator directed that job results be printed from disk
• Disks enabled simultaneous peripheral operation on-line (spooling)
• Computer overlapped I/O of one job with execution of another
• Better utilization of the expensive CPU
• Still only one job active at any given time
Operating Systems 17
Third generation:
multiprogramming
• Multiple jobs in memory
• Protected from one
Job 3 another
• Operating system protected
from each job as well
Job 2 • Resources (time, hardware) split
between jobs
Memory
partitions Job 1 • Still not interactive
• User submits job
• Computer runs it
• User gets results minutes
Operating (hours, days) later
system
Operating Systems 18
Timesharing systems
• It’s a logical extension of multiprogramming.
• The CPU executes multiple jobs by switching among them
• It allows many users to share the computer simultaneously
• It uses time scheduling and multiprogramming to provide
each user with a small portion of a time shared computer.
• Its more complex than multiprogramming because jobs may
have to be swapped in and out of main memory.
• Here it comes virtual memory
Operating Systems 19
Desktop Systems
• Personal computers – computer system dedicated to a single user.
• I/O devices – keyboards, mice, display screens, small printers.
• 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)
Operating Systems 20
Parallel Systems
• Multiprocessor systems with more than on CPU in close
communication.
• Tightly coupled system – processors share memory and a clock;
communication usually takes place through the shared memory.
• Advantages of parallel system:
• Increased throughput
• Economical
• Increased reliability
• graceful degradation
• fail-soft systems
Operating Systems 21
Parallel Systems (Cont.)
• Symmetric multiprocessing (SMP)
• Each processor runs and identical copy of the operating
system.
• Many processes can run at once without performance
deterioration.
• Most modern operating systems support SMP
• Asymmetric multiprocessing
• Each processor is assigned a specific task; master processor
schedules and allocated work to slave processors.
• More common in extremely large systems
Operating Systems 22
Symmetric Multiprocessing
Architecture
Operating Systems 23
Distributed Systems
• Distribute the computation among several physical
processors.
• 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.
• Advantages of distributed systems.
• Resources Sharing
• Computation speed up – load sharing
• Reliability
• Communications
Operating Systems 24
Distributed Systems
(cont.)
Operating Systems 25
General Structure of
Client-Server
Operating Systems 26
Handheld Systems
• Personal Digital Assistants (PDAs)
• Cellular telephones
• Issues:
• Limited memory
• Slow processors
• Small display screens.
Operating Systems 27
Clustered Systems
• 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
Mass-Storage
Management
• Usually disks used to store data that does not fit in main memory or
data that must be kept for a “long” period of time
• Proper management is of central importance
• Entire speed of computer operation hinges on disk subsystem and its
algorithms
• OS activities
• Free-space management
• Storage allocation
• Disk scheduling
• Some storage need not be fast
• Tertiary storage includes optical storage, magnetic tape
• Still must be managed – by OS or applications
• Varies between WORM (write-once, read-many-times) and RW
(read-write)
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
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
Computing Environments - Traditional
• Stand-alone general purpose machines
• But blurred as most systems interconnect with others (i.e., the
Internet)
• Portals provide web access to internal systems
• Network computers (thin clients) are like Web terminals
• Mobile computers interconnect via wireless networks
• Networking becoming ubiquitous – even home systems use firewalls to
protect home computers from Internet attacks
Computing Environments - Mobile
• Soft real-time
• Limited utility in industrial control of robotics
• Useful in applications (multimedia, virtual reality) requiring
advanced operating-system features.
Operating Systems 51
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 ppt are generic
Example of System Calls
• System call sequence to copy the contents of one
file to another file
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
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
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
Types of System Calls
(Cont.)
• Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Examples of Windows and Unix System
Calls
Standard C Library Example
• C program invoking printf() library call, which calls
write() system call
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
Simple Structure -- MS-
DOS
• MS-DOS – written to
provide the most
functionality in the least
space
• Not divided into
modules
• Although MS-DOS has
some structure, its
interfaces and levels of
functionality are not
well separated
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
Traditional UNIX System
Structure
Beyond simple but not fully layered
Layered Approach