Operating Systems (IIOS-332C)
Introduction to Operating
Systems
• All desktop computers use an operatingsystem.
• Common desktop operating systems include:– Windows
– Unix
– Linux
• There are hundreds of other operatingsystems available for special-purposeapplications e.g. mobile phones, PDAs etc.
What is an Operating System?
• A program that acts as an intermediary between
a user of a computer and the computer hardware.
• 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.
Operating System Definition
• OS is a resource allocator
– Manages all resources
– Decides between conflicting requests for
efficient and fair resource use
• OS is a control program
– Controls execution of programs to prevent
errors and improper use of the computer
Resources of Computer System
Computer System
Processor
Memory and
Disks
Files
Input Output Devices
5
Computer System Structure
Computer System
Software
System Software
Application Software
Hardware
Language
Translators
Operating
system
Four Components of a Computer
System
8
Components of an Operating
System
Operating system – part of the computing system
that manages all of the hardware and all of the
software
– Controls every file, device, section of main memory &
every nanosecond of processing time
• Memory manager
• Processor manager
• Device manager
• File manager
Operating system
consists of
9
Coordination of Operating System
10
Types of Operating Systems
• GUI
• Examples
– Windows: Everything is presented to user graphically
– Mac OSX
– Linux running xWindows
• CUI
• Examples
– MS-DOS
– Unix
Types of Operating Systems
• Single user OS
– MS-DOS
– Windows 1.0
– Windows 2.x , Windows 3.x , Windows 95
Windows 98, Windows ME
• Multi user OS
– Unix, Windows NT, 2000, XP
11
Types of Operating Systems
• Single User
– Serial Processing OS
• Working in serial manner: Card Reader
– Batch Processing OS
• Batch of jobs can be executed together.
12
13
Types of Operating Systems
• Serial Processing
– No operating system
– Machines run from a console with display lights, toggle
switches, input device, and printer
– Schedule time
– Setup included loading the compiler, source program,
saving compiled program, and loading and linking
14
Types of Operating Systems
• Simple Batch Systems• Software that controls the sequence of events
• Batch jobs together
• Example: The concept of batch files in DOS and Unix.
Types of Operating Systems
• Types of Multi User OS
– Multiprogramming OS
– Time Sharing OS
– Multiprocessing OS
15
Why Multiprogramming
• To have maximum utilization of
the CPU
16
17
The CPU is wasted if a job waits for I/O. This leads to:
– Multiprogramming (dynamic switching ). Whileone job waits for a resource, the CPU can findanother job to run. It means that several jobsare ready to run and only need the CPU in orderto continue.
All of this leads to:
– memory management
– resource scheduling
– deadlock protection
Why Multiprogramming
Why Time Sharing
• Time Sharing - multiprogramming
environment that's also interactive.
• Fair Scheduling is also important……
18
Working of Processor
• In Uniprogramming Way….
• In Multiprogramming Way…..
19
20
Uniprogramming
• Processor must wait for I/O instruction to
complete before preceding
21
Multiprogramming
• When one job needs to wait for I/O, the
processor can switch to the other job
22
Multiprogramming
23
Time Sharing
• Using multiprogramming to handle multiple
interactive jobs
• Processor’s time is shared among multiple users
• Multiple users simultaneously access the system
through terminals
24
• Multiprocessing- Specific applications….
• Multiple Processor may be there…..
• System can communicate via shared memory…..
• Speed improvement by putting together anumber of processors.
.
Why Multiprocessing
Types of Operating Systems
• Multi User OS
– Distributed Operating System
– Network Operating System
25
Distributed Operating System
A distributed system is a collection of
autonomous computers that appear to
the users of the system as a single
computer.
27
• Distributed Systems - communicate viamessage passing.
• Advantages include resource sharing, speedup, reliability, communication.
• There is a single system image
Why Distributed OS
• By contrast, one could imagine an operating
system in which users are never concerned with
where their programs run, or the location of any
resources.
• The operating system has control over all the
nodes in the system, and it transparently locates
new processes at whatever node suits its
scheduling policies.
Distributed Operating System
Why Distributed Systems?
• Resource sharing
• Scalability
• Reliability
• Need for higher processing speed
• Spatial distribution is inherent in many applications
Network Operating System
• It provides an environment where users are
aware of the multiplicity of machines.
• Users can access remote resources by
– logging into the remote machine OR
– transferring data from the remote machine to
their own machine
• Users should know where the required files
and directories are….
• Each machine could act like a server and a
client at the same time.
Types of Operating Systems
• Special Operating System
– Real Time Operating System
• Hard Real Time
• Soft Real Time
31
32
What are Real-time Systems ?
Those systems in which the correctness of the
system depends not only on the logical result of
computation, but also on the time at which the
results are produced.
33
Types of Real Time Systems
• Based on Hard deadline: Penalty due to missing
deadline is a higher order of magnitude than the
Reward in meeting the deadline.
• Based on Soft deadline: Penalty often equal /
lesser magnitude than Reward.
Soft RTOS…
• In a soft real-time system, it is considered undesirable, but not catastrophic, if deadlines are occasionally missed.
• Also known as “best effort” systems
• Most modern operating systems can serve as the base for a soft real time systems.
• Examples:
– multimedia transmission and reception,
– networking, telecom (cellular) networks,
– web sites and services
– computer games.
Hard RTOS…
• A hard real-time system has time-critical deadlines that must be met; otherwise a catastrophic system failure can occur.
• Absolutely, positively, first time every time
• Requires formal verification/guarantees of being to always meet its hard deadlines (except for fatal errors).
• Examples:
– air traffic control
– vehicle subsystems control
– Nuclear power plant control
Types of Operating Systems
• Special Operating System
– Embedded Operating System
– Parallel Operating System
36
What is an Embedded OS?
• An "embedded system" is any computer system or
computing device that performs a dedicated function
or is designed for use with a specific embedded
software application.
• Embedded systems may use a ROM-based
operating system or they may use a disk-based
system, like a PC. But an embedded system is not
usable as a commercially viable substitute for
general purpose computers or devices.
Example of Parallel Processing
Environment
MPP Massively Parallel ProcessorSMP Symmetric Multi-Processor
cpu cpu cpu
Fast Interconnect
Memory (shared)
cpu
Mem
cpu
Mem
cpu
Mem
Interconnect (varies)
P PP P P P..
Microkernel
Multi-Processor Computing System
Threads Interface
Hardware
Operating System
ProcessProcessor ThreadP
Applications
Parallel Computing
Environment
Programming paradigms
40
Brief History of Operating
Systems Development
1940 1955 1965 1980
1990
First Generation
Vacuum tube, single
user, early operating
systems
Second Generation
Job scheduling, JCL,
faster I/O, spooling,
batch, files
Third Generation
Shared processing,
multiprogramming, virtual
memory, DBMS
Recent Developments
Distributed computing,
personal computers, high-
speed communication, multi-
media
Syllabus
• Operating System Structures
– General OS task: resource mgmt, Sharing & Protection
– OS Interfaces: shells, API, system calls
– Architecture of OS
– Layered system design
– Microkernels
– Modularized approach
– Virtual Machines
– System Boot process
41
Syllabus
• Process Concept
• Overview
• Scheduling
• Operations
• Interprocess Communication
• Process Vs. Thread
• Multithreaded Programming
42
Syllabus
• Process Scheduling
– Scheduling Criteria
– Scheduling Algorithm
– Multi-Processor Scheduling
– Algorithm Evaluation
43
Syllabus
• Process Synchronization
– Mutual exclusion
– Critical sections
– Classical synchronization problems
– Bounded Buffers
– Readers/writers
– Dining Philosophers
– Atomic transactions (cf. databases)
– Logging, UNDO/REDO recovery
– Concurrency Control, Serializability, Locking Time-
Stamping 44
Syllabus
Deadlocks
• Define the problem, give necessary conditions!– Graph-based models (single vs. multiple resources per type)
– Resource Allocation Graph
– Wait-For Graph
• Deadlock Prevention and Detection
• How/when can we detect that the system/some
processes is/are in a deadlock state?
• Recovery from deadlock
• If we detected a deadlock: how to resolve the
situation? 45
Syllabus
• Memory Management
– Background
– Swapping
– Memory Allocation Techniques
– Paging
– Segmentation
46
Syllabus
• Virtual- Memory Management
– Background
– Demand Paging
– Copy-on-Write
– Page Replacement
– Allocation of Frames
– Thrashing
47
Syllabus
• File Management
– File Concept
– Access Methods
– Directory Structure
– File System Mounting
– File Sharing
– Protection
48
Syllabus
• Implementing File System
– File System Structure
– File System Implementation
– Directory Implementation
– Allocation Methods
– Free Space Management
49
Syllabus
• Mass Storage Structure
– Physical characteristics & performance
determinants of disk technology
– Connecting disks and processors
– Disk scheduling
– Different algorithms with their pros & cons
– Overcoming disk failures
– Storage hierarchy, tertiary storage
50
Syllabus
• I/O Systems
– Transforming application-level commands into device
operations
– Analyze the steps necessary & point out major OS
tasks
– Ports, polling, interrupts, DMA, device drivers, kernel
I/O
– Show how interrupt handling is done in the OS!
– Why several levels (priorities), masking, etc.?
– Blocking vs. non-blocking vs. asynchronous I/O
– Give an example, show principal steps of interaction
between user process and OS components 51
Syllabus
• Protection
– Goals, principles, mechanisms of protection
– Model used for protection (objects, domains, access-
rights)
– Access matrix
– Addition of rights
– Revocation of rights
– Capabilities vs. access control lists
– Roles
52
Points to note…………
• Major areas
– Processor Management
– Memory Management
– File Management
– Disk Management
– Input/ Output Management
53
Functions of an OS
• Processor management
• Memory management
• Device management
• Storage management
• Application interface
• User interface
Processor Management
• The OS has tomanage theexecution ofprocesses so thatyou believe thatthere are severalthings happeningat once.
Processor Management
56
However, the processor can only do onething at a time.
In order to give the appearance of lots ofthings happening at the same time, the OShas to switch between different processesthousands of times a second making surethat each process and application receivesenough of the processor's time to functionproperly.
Memory Management
• The OS manages memory (RAM). Whenapplications are loaded they need memory to workwith. The OS allocates software RAM to work in. Itensures that the RAM allocated is not used byanother application.
• The OS also manages virtual memory. In thisway the computer can run more applications thanit has RAM for. For example if a computer wasrunning a word processor and the user wanted toload a spreadsheet application at the same timeand there was not enough RAM then the OS usesthe hard disc as virtual RAM.
Device Management (Input/Output)
• The OS makes use of queues and buffers, specialstorage facilities that take a stream of bits (data)from a device, e.g. a keyboard, hold those bits, andthen release them to the CPU at a rate slow enoughfor the CPU to cope with.
• This function is very important when a number ofprocesses are running and taking up processortime. The OS will instruct a buffer to continue takinginput from the device, but to stop sending data tothe CPU while the process using the input issuspended. Then, when the process needing inputis made active once again, the OS will commandthe buffer to send data.
Device Management (Drivers)
• The operating system needs to communicate withthe various hardware components which make upthe computer. Special programs called driversenable the OS to communicate with these hardwaredevices. Drivers are needed as the hardware whichmakes up a PC may be vastly different to that ofanother PC with the same OS installed.
• Drivers are translation programs which convert themessages from the OS into messages that thehardware device can understand.
User Interface
• The user interface (UI) brings structure to the interaction between a user and the computer.
GUI
61
Operating Systems in Practice
MS-DOS Operating System
Windows Operating System
UNIX/Linux Operating System
IBM OS/390 Operating System
Open Source Operating System
62
Operating System Objectives
• Convenience
– Makes the computer more convenient to use
• Efficiency
– Allows computer system resources to be used in an
efficient manner
• Ability to evolve
– Permit effective development, testing, and introduction
of new system functions without interfering with service
63
Services Provided by the
Operating System
• Program development
– Editors and debuggers
• Program execution
• Access to I/O devices
• Controlled access to files
• System access
64
Services Provided by the
Operating System
• Error detection and response
– Internal and external hardware errors
• Memory error
• Device failure
– Software errors
• Arithmetic overflow
• Access forbidden memory locations
– Operating system cannot grant request of application
65
Services Provided by the
Operating System
• System Accounting
– Collect usage statistics
– Monitor performance
– Used to anticipate future enhancements
66
Kernel
• Portion of operating system that is in main
memory
• Contains most frequently used functions
• Also called the nucleus
67
Job Control Language (JCL)
• Special type of programming language
• Provides instruction to the monitor an executing
unit
– What compiler to use
– What data to use
68
Processes
• A program in execution
• An instance of a program running on a computer
• The entity that can be assigned to and executedon a processor
• A unit of activity characterized by a singlesequential thread of execution, a current state,and an associated set of system resources
69
Difficulties with Designing
System Software
• Improper synchronization
– Ensure a process waiting for an I/O device receives the
signal
• Failed mutual exclusion
• Nondeterminate program operation
– Program should only depend on input to it, not on the
activities of other programs
• Deadlocks
70
Process
• Consists of three components
– An executable program
– Associated data needed by the program
– Execution context of the program
• All information the operating system needs to manage the
process
71
Memory Management
• Process isolation
• Automatic allocation and management
• Support of modular programming
• Protection and access control
• Long-term storage
72
Virtual Memory
• Allows programmers to address memory from a
logical point of view
• No gap between the execution of successive
processes while one process was written out to
secondary store and the successor process was
read in
73
Virtual Memory and File
System
• Implements long-term store
• Information stored in named objects called files
74
Information Protection and
Security
• Availability
– Concerned with protecting the system against
interruption
• Confidentiality
– Assuring that users cannot read data for which access
is unauthorized
75
Information Protection and
Security
• Data integrity
– Protection of data from unauthorized modification
• Authenticity
– Concerned with the proper verification of the identity of
users and the validity of messages or data
76
Scheduling and Resource
Management
• Fairness
– Give equal and fair access to resources
• Differential responsiveness
– Discriminate among different classes of jobs
• Efficiency
– Maximize throughput, minimize response
time, and accommodate as many uses as
possible
77
System Structure
• View the system as a series of levels
• Each level performs a related subset of functions
• Each level relies on the next lower level to perform
more primitive functions
• This decomposes a problem into a number of
more manageable subproblems
78
Modern Operating Systems
• Multithreading
– Process is divided into threads that can run
concurrently
• Thread
– Dispatchable unit of work
– executes sequentially and is interruptable
• Process is a collection of one or more threads
79
Modern Operating Systems
• Symmetric multiprocessing (SMP)
– There are multiple processors
– These processors share same main memory and I/O
facilities
– All processors can perform the same functions
Characteristics of Modern
Operating Systems
• Microkernel architecture
– assigns only a few essential functions to the kernel
• address space
• interprocess communication (IPC)
• basic scheduling
Characteristics of Modern
Operating Systems
• Multithreading
– process is divided into threads that can run
simultaneously
• Thread
– dispatchable unit of work
– executes sequentially and is interruptable
• Process is a collection of one or more threads
Characteristics of Modern
Operating Systems
• Symmetric multiprocessing
– there are multiple processors
– these processors share same main memory and I/O
facilities
– All processors can perform the same functions
Characteristics of Modern
Operating Systems
• Distributed operating systems
– provides the illusion of a single main memory and
single secondary memory space
– used for distributed file system
Characteristics of Modern
Operating Systems
• Object-oriented design
– used for adding modular extensions to a small kernel
– enables programmers to customize an operating
system without disrupting system integrity