0% found this document useful (0 votes)
84 views70 pages

CH 1

The document provides an overview of operating systems including their structure, functions, and history. It discusses early systems, batch processing systems, and how multiprogramming and timesharing led to more efficient use of resources and improved user experience. The document also covers open-source operating systems and chapter objectives.

Uploaded by

Enock
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views70 pages

CH 1

The document provides an overview of operating systems including their structure, functions, and history. It discusses early systems, batch processing systems, and how multiprogramming and timesharing led to more efficient use of resources and improved user experience. The document also covers open-source operating systems and chapter objectives.

Uploaded by

Enock
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Operating Systems

Operating Systems

1.2
Operating Systems

1.3
Course Objective
 This course is an introductory course in
operating systems (OS), focusing on the core
concepts of operating systems.
 Processes and Threads
 Memory Management
 Storage and File Systems
 I/O Systems
 Establish a foundation for building higher-
level programs
 How to optimize programs
 How to debug large systems
 How to deal with complexity

1.4
Logistics

 Lectures
 Friday 10:35-12:00, 24-404
 Instructor
 Asso. Prof. Xiangbin Zhu

 Course Web Page(在线教学平台)


 Assignments, lectures, and other supplemental materials will
be on the web site

1.5
Administrative
 Course has five components
 Lectures
 Homework
 Experiments
 Projects
 Quizzes

 Textbook
 Silberschatz, Galvin & Gagne
 Operating System Concepts, 7th/9th ed.

1.6
Grading

 Grading Policy Breakdown


 Homework - 15% of the final grade
 Experiments(Linux) - 15% of the final grade
 Projects – 10% of the final grade
 Final exam - 50% of the final grade
 Participation- 5% of the final grade
 Quizzes- 5% of the final grade

1.7
Chapter 1: Introduction
 What Operating Systems Do
 Computer-System Organization
 Operating-System Structure
 Operating-System Operations
 Computing Environments
 Open-Source Operating Systems

1.8
Objectives

 To describe the basic organization of computer


systems
 To provide a grand tour of the major components
of operating systems
 To give an overview of the many types of
computing environments
 To explore several open-source operating
systems

Note: most of the slides and/or pictures in the following are


adapted from slides ©2013 Silberschatz, Galvin, and Gagne.

1.9
Computer System Structure

 Computer system can be divided into four


components:
 Hardware – provides basic computing resources
 CPU, memory, I/O devices
 Operating system
 Application programs – define the ways in which the
system resources are used to solve the computing
problems of the users
 Word processors, compilers, web browsers, database
systems, video games
 Users
 People, machines, other computers

1.10
Abstract View of System

User
1 User User User
2 3 ... n

compiler assembler Text editor Database


system
System and Application Programs

Operating System

Computer
Hardware

1.11
What is an Operating System?
 Definition has changed over years
 Originally, very bare bones
 Now, includes more and more
 Operating System(OS)
 Interface between the user and the architecture
 Implements a virtual machine that is hopefully easier to
program than raw 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
 Make application software portable and versatile
 Provide isolation, security and protection among user programs
 Improve overall system reliability
1.12
Top-Level View of an OS

1.13
OS Provides Abstraction

APP: • Easy to program Apps


• No more hardware details for
printf(“%s”, str); programmers
• Reusable functionality
System Call • Portable
Write to STDOUT • OS interfaces are consistent.
The App does not change
Operating System when hardware changes.

Device Driver

Graphics Card

1.14
Operating System Definition

 No universally accepted
definition
 “Everything a vendor ships
when you order an operating
system” is a good approximation
 But varies wildly
 “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.
1.15
What Operating Systems Do
User View:
 Users want convenience, ease of use and good
performance
 Don’t care about resource utilization
 But shared computer such as mainframe or minicomputer
must keep all users happy
 Users of dedicate systems such as workstations have
dedicated resources but frequently use shared resources
from servers
 Handheld computers are resource poor, optimized for
usability and battery life
 Some computers have little or no user interface, such as
embedded computers in devices and automobiles

1.16
What Operating Systems Do
System View:
 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

1.17
OS is a resource allocator

1.18
Operating System Spectrum

 Monitors and Small Kernels


 special purpose and embedded systems, real-time systems

 Batch and multiprogramming


 Timesharing
 workstations, servers, minicomputers

 Transaction systems
 Personal Computing Systems
 Mobile Platforms, devices (of all sizes)

1.19
Early Systems - Bare Machine (1950s)

Hardware – expensive ; Human – cheap


 Structure
 Large machines run from console
 Single user system
– Programmer/User as operator
 Paper tape or punched cards

 Early software
 Assemblers, compilers, linkers, loaders, device drivers, libraries of
common subroutines.

 Secure execution
 Inefficient use of expensive resources
 Low CPU utilization, high setup time.

1.20
punch card

1.21
1.22
Simple Batch Systems (1960’s)
 Reduce setup time by batching jobs with similar requirements.
 Add a card reader, Hire an operator
 User is NOT the operator
 Automatic job sequencing
 Forms a rudimentary OS.

 Resident Monitor From John Ousterhout slides

 Holds initial control, control transfers to job and then back to


monitor.
 Problem
 Need to distinguish job from job and data from program.

1.23
Supervisor/Operator Control
 Secure monitor that controls job processing
 Special cards indicate what to do.
 User program prevented from performing I/O
 Separate user from computer
 User submits card deck IBM 7094
 cards put on tape
 tape processed by operator
 output written to tape
 tape printed on printer
 Problems
 Long turnaround time - up to 2 DAYS!!!
 Low CPU utilization
– I/O and CPU could not overlap; slow mechanical devices.

1.24
Batch Systems - Issues
 Solutions to speed up I/O:
 Offline Processing
 load jobs into memory from tapes, card reading and line
printing are done offline.
 Spooling
 Use disk (random access device) as large storage for reading
as many input files as possible and storing output files until
output devices are ready to accept them.
 Allows overlap - I/O of one job with computation of another.
 Introduces notion of a job pool that allows OS choose next job
to run so as to increase CPU utilization.

1.25
1.26
Batch Systems - I/O completion

 How do we know that I/O is complete?


 Polling:
Device sets a flag when it is busy.
Program tests the flag in a loop waiting for
completion of I/O.
 Interrupts:
On completion of I/O, device forces CPU to jump to
a specific instruction address that contains the
interrupt service routine.
After the interrupt has been processed, CPU
returns to code it was executing prior to servicing
the interrupt.
1.27
Multiprogramming

 Use interrupts to run multiple programs


simultaneously
When a program performs I/O, instead of
polling, execute another program till
interrupt is received.
 Requires secure memory, I/O for each program.
 Requires intervention if program loops
indefinitely.
 Requires CPU scheduling to choose the next job
to run.

1.28
IBM/360

1.29
Example: Uniprogramming
(only one program running on the system)

What is the CPU Utilization?

1.30
Example: Multiprogramming
(multiple programs simultaneously running)

1.31
Timesharing
Hardware – getting cheaper; Human – getting expensive
 Programs queued for execution in FIFO order.
 Like multiprogramming, but timer device interrupts after
a quantum (timeslice).
 Interrupted program is returned to end of FIFO
 Next program is taken from head of FIFO

 Control card interpreter replaced by command language


interpreter.

1.32
Timesharing (cont.)

 Interactive (action/response)
 when OS finishes execution of one command, it seeks the next
control statement from user.
 File systems
 online filesystem is required for users to access data and code.

 Virtual memory
 Job is swapped in and out of memory to disk.

1.33
Personal Computing Systems
Hardware – cheap ; Human – expensive

 Single user systems, portable.


 I/O devices - keyboards, mice, display screens, small
printers.
 Laptops and palmtops, Smart cards, Wireless devices.
 Single user systems may not need advanced CPU
utilization or protection features.
 Advantages:
 user convenience, responsiveness, ubiquitous

1.34
Parallel Systems

 Multiprocessor systems with more than one CPU in


close communication.
 Improved throughput, economical, increased reliability.
 Kinds:
– Vector and pipelined
– Symmetric and asymmetric multiprocessing
– Distributed memory vs. shared memory

 Programming models:
– Tightly coupled vs. loosely coupled ,message-based vs. shared
variable

1.35
Parallel Computing Systems

ILLIAC 2
(UIllinois) Climate modeling,
earthquake
simulations, genome
analysis, protein
folding, nuclear fusion
research, ….. K-
computer(Japan
)

Tianhe-1(China)

IBM Blue Gene

Connection Machine
(MIT)
1.36
Distributed Systems
Hardware – very cheap ; Human – very expensive

 Distribute computation among many processors.


 Loosely coupled -
– no shared memory, various communication lines

 client/server architectures
 Advantages:
– resource sharing
– computation speed-up
– reliability
– communication - e.g. email

 Applications - digital libraries, digital multimedia

1.37
Distributed Computing Systems

Globus Grid Computing Toolkit Cloud Computing Offerings

PlanetLab Gnutella P2P Network

1.38
Real-time systems

 Correct system function depends on timeliness


 Feedback/control loops
 Sensors and actuators
 Hard real-time systems –
 Failure if response time too long.
 Secondary storage is limited

 Soft real-time systems -


 Less accurate if response time is too long.
 Useful in applications such as multimedia, virtual reality.

1.39
Computer System Organization

 Computer-system operation
 One or more CPUs, device controllers connect through
common bus providing access to shared memory
 Concurrent execution of CPUs and devices competing for
memory cycles

1.40
Computer Startup

 bootstrap program is loaded at power-up


or reboot
 Typically stored in ROM or EPROM, generally
known as firmware
 Initializes all aspects of system
 Loads operating system kernel and starts
execution

1.41
Computer-System Operation

 I/O devices and the CPU can execute


concurrently
 Each device controller is in charge of a
particular device type
 Each device controller has a local buffer
 CPU moves data from/to main memory
to/from local buffers
 I/O is from the device to local buffer of
controller
 Device controller informs CPU that it has
finished its operation by causing an interrupt

1.42
Common Functions of Interrupts

 Interrupt transfers control to the interrupt


service routine generally, through the
interrupt vector, which contains the
addresses of all the service routines
 Interrupt architecture must save the address
of the interrupted instruction
 A trap or exception is a software-generated
interrupt caused either by an error or a user
request
 An operating system is interrupt driven

1.43
Interrupt Handling

 The operating system preserves the state of


the CPU by storing registers and the
program counter
 Determines which type of interrupt has
occurred:
 polling
 vectored interrupt system
 Separate segments of code determine what
action should be taken for each type of
interrupt

1.44
Interrupt Timeline

1.45
I/O Structure

 After I/O starts, control returns to user program


only upon I/O completion
 Wait instruction idles the CPU until the next interrupt
 Wait loop (contention for memory access)
 At most one I/O request is outstanding at a time, no
simultaneous I/O processing
 After I/O starts, control returns to user program
without waiting for I/O completion
 System call – request to the OS to allow user to
wait for I/O completion
 Device-status table contains entry for each I/O
device indicating its type, address, and state
 OS indexes into I/O device table to determine device
status and to modify table entry to include interrupt

1.46
Storage Structure
 Main memory – only large storage media that the
CPU can access directly
 Random access
 Typically volatile

 Secondary storage – extension of main memory that


provides large nonvolatile storage capacity
 Hard disks – rigid metal or glass platters covered
with magnetic recording material
 Disk surface is logically divided into tracks, which are subdivided into
sectors
 The disk controller determines the logical interaction between the device
and the computer

 Solid-state disks – faster than hard disks,


nonvolatile
 Various technologies
 Becoming more popular
1.47
Storage Hierarchy

 Storage systems organized in hierarchy


 Speed
 Cost
 Volatility
 Caching – copying information into faster
storage system; main memory can be
viewed as a cache for secondary storage
 Device Driver for each device controller to
manage I/O
 Provides uniform interface between controller
and kernel

1.48
Storage-Device Hierarchy

1.49
Caching

 Important principle, performed at many levels


in a computer (in hardware, operating
system, software)
 Information in use copied from slower to
faster storage temporarily
 Faster storage (cache) checked first to
determine if information is there
 If it is, information used directly from the cache
(fast)
 If not, data copied to cache and used there
 Cache smaller than storage being cached
 Cache management important design problem
 Cache size and replacement policy
1.50
Direct Memory Access Structure

 Used for high-speed I/O devices able to


transmit information at close to memory
speeds
 Device controller transfers blocks of data
from buffer storage directly to main
memory without CPU intervention
 Only one interrupt is generated per block,
rather than the one interrupt per byte

1.51
How a Modern Computer Works

A von Neumann architecture

1.52
Operating System Structure

 Multiprogramming (Batch system) needed for efficiency


 Single user cannot keep CPU and I/O devices busy at all times
 Multiprogramming organizes jobs (code and data) so CPU always has one
to execute
 A subset of total jobs in system is kept in memory
 One job selected and run via job scheduling
 When it has to wait (for I/O for example), OS switches to another job

 Timesharing (multitasking) is logical extension in which CPU


switches jobs so frequently that users can interact with each job while it is
running, creating interactive computing
 Response time should be < 1 second
 Each user has at least one program executing in memory process
 If several jobs ready to run at the same time  CPU scheduling
 If processes don’t fit in memory, swapping moves them in and out to run
 Virtual memory allows execution of processes not completely in
memory
1.53
Memory Layout for Multiprogrammed System

1.54
Operating-System Operations

 Interrupt driven (hardware and software)


 Hardware interrupt by one of the devices
 Software interrupt (exception or trap):
 Software error (e.g., division by zero)
 Request for operating system service
 Other process problems include infinite loop, processes
modifying each other or the operating system

1.55
Operating-System Operations (cont.)

 Dual-mode operation allows OS to protect itself


and other system components
 User mode and kernel mode
 Mode bit provided by hardware
 Provides ability to distinguish when system is running user
code or kernel code
 Some instructions designated as privileged, only
executable in kernel mode
 System call changes mode to kernel, return from call resets
it to user

1.56
Transition from User to Kernel Mode

 Timer to prevent infinite loop / process hogging


resources
 Timer is set to interrupt the computer after some time period
 Keep a counter that is decremented by the physical clock.
 Operating system set the counter (privileged instruction)
 When counter zero generate an interrupt
 Set up before scheduling process to regain control or
terminate program that exceeds allotted time

1.57
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

1.58
Computing Environments - Mobile

 Handheld smartphones, tablets, etc


 What is the functional difference between
them and a “traditional” laptop?
 Extra feature – more OS features (GPS,
gyroscope)
 Allows new types of apps like augmented
reality
 Use IEEE 802.11 wireless, or cellular data
networks for connectivity
 Leaders are Apple iOS and Google Android

1.59
Computing Environments – Distributed

 Distributed computiing
 Collection of separate, possibly heterogeneous, systems
networked together
 Network is a communications path, TCP/IP most common
– Local Area Network (LAN)
– Wide Area Network (WAN)
– Metropolitan Area Network (MAN)
– Personal Area Network (PAN)
 Network Operating System provides features between
systems across network
 Communication scheme allows systems to exchange
messages
 Illusion of a single system

1.60
Computing Environments – Client-Server

 Client-Server Computing
 Dumb terminals supplanted by smart PCs
 Many systems now servers, responding to requests generated
by clients
 Compute-server system provides an interface to client to
request services (i.e., database)
 File-server system provides interface for clients to store
and retrieve files

1.61
Computing Environments - Peer-to-Peer

 Another model of distributed


system
 P2P does not distinguish clients
and servers
 Instead all nodes are considered peers
 May each act as client, server or both
 Node must join P2P network
 Registers its service with central lookup
service on network, or
 Broadcast request for service and
respond to requests for service via
discovery protocol
 Examples include Napster and
Gnutella, Voice over IP (VoIP) such as
Skype
1.62
Computing Environments - Virtualization
 Allows operating systems to run applications
within other OSes
 Vast and growing industry
 Emulation used when source CPU type
different from target type (i.e. PowerPC to Intel
x86)
 Generally slowest method
 When computer language not compiled to native
code – Interpretation
 Virtualization – OS natively compiled for CPU,
running guest OSes also natively compiled
 Consider VMware running WinXP guests, each
running applications, all on native WinXP host OS
 VMM (virtual machine Manager) provides
virtualization services 1.63
Computing Environments - Virtualization

 Use cases involve laptops and desktops running


multiple OSes for exploration or compatibility
 Apple laptop running Mac OS X host, Windows as a
guest
 Developing apps for multiple OSes without having
multiple systems
 QA testing applications without having multiple
systems
 Executing and managing compute environments
within data centers
 VMM can run natively, in which case they are
also the host
 There is no general purpose host then (VMware ESX
and Citrix XenServer)
1.64
Computing Environments - Virtualization

1.65
Computing Environments – Cloud Computing
 Delivers computing, storage, even apps as a service across a
network
 Logical extension of virtualization because it uses virtualization as
the base for it functionality.
 Amazon EC2 has thousands of servers, millions of virtual
machines, petabytes of storage available across the Internet,
pay based on usage
 Many types
 Public cloud – available via Internet to anyone willing to pay
 Private cloud – run by a company for the company’s own use
 Hybrid cloud – includes both public and private cloud
components
 Software as a Service (SaaS) – one or more applications
available via the Internet (i.e., word processor)
 Platform as a Service (PaaS) – software stack ready for
application use via the Internet (i.e., a database server)
 Infrastructure as a Service (IaaS) – servers or storage available
over Internet (i.e., storage available
1.66
for backup use)
Computing Environments – Cloud Computing

 Cloud computing environments composed of


traditional OSes, plus VMMs, plus cloud
management tools
 Internet connectivity requires security like firewalls
 Load balancers spread traffic across multiple
applications

1.67
Computing Environments – Real-Time Embedded Systems

 Real-time embedded systems most prevalent


form of computers
 Vary considerable, special purpose, limited purpose
OS, real-time OS
 Use expanding
 Many other special computing environments as
well
 Some have OSes, some perform tasks without an OS
 Real-time OS has well-defined fixed time
constraints
 Processing must be done within constraint
 Correct operation only if constraints met

1.68
Open-Source Operating Systems

 Operating systems made available in source-


code format rather than just binary closed-
source
 Counter to the copy protection and Digital
Rights Management (DRM) movement
 Started by Free Software Foundation (FSF),
which has “copyleft” GNU Public License
(GPL)
 Examples include GNU/Linux and BSD UNIX
(including core of Mac OS X), and many more
 Can use VMM like VMware Player (Free on
Windows), Virtualbox (open source and free on
many platforms - http://www.virtualbox.com)
 Use to run guest operating systems for exploration
1.69
End of Chapter 1

You might also like