lecture1

advertisement
Chapter 1: Introduction
Operating System Concepts Essentials – 9th Edition
Silberschatz, Galvin and Gagne ©2013
Chapter 1: Introduction
 What Operating Systems Do
 Computer-System Organization
 Computer-System Architecture
 Operating-System Structure
 Operating-System Operations
 Process Management
 Memory Management
 Storage Management
 Protection and Security
 Kernel Data Structures
 Computing Environments
 Open-Source Operating Systems
Operating System Concepts Essentials – 9th Edition
1.2
Silberschatz, Galvin and Gagne ©2013
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
Operating System Concepts Essentials – 9th Edition
1.3
Silberschatz, Galvin and Gagne ©2013
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 Concepts Essentials – 9th Edition
1.4
Silberschatz, Galvin and Gagne ©2013
Computer System Structure

Computer system can be divided into four components:
 Hardware – provides basic computing resources
 CPU, memory, I/O devices
 Machine language: small set of instructions to move data around,
do arithmetic, compare values, etc. visible to an assembly
language programmer.
 Operating system/Kernel
 Controls and coordinates use of hardware among various
applications and users
 Protected from user modification by hardware (kernel mode)
 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
 User mode
 Users
 People, machines, other computers
Operating System Concepts Essentials – 9th Edition
1.5
Silberschatz, Galvin and Gagne ©2013
Four Components of a Computer System
Operating System Concepts Essentials – 9th Edition
1.6
Silberschatz, Galvin and Gagne ©2013
What Operating Systems Do
 Depends on point of view
 Single 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 (e.g.
file, print 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. Their Oss
designed to run without user intervention.
Operating System Concepts Essentials – 9th Edition
1.7
Silberschatz, Galvin and Gagne ©2013
Two views of an Operating System
 OS is a resource allocator

Manages all resources

Orderly and controlled allocation of disk space, memory,
CPU time, I/O devices, access to network

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

Present the user with an extended machine: Hides the
complexity of the hardware, provides a simpler interface
Operating System Concepts Essentials – 9th Edition
1.8
Silberschatz, Galvin and Gagne ©2013
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

CPU registers, device drivers, memory, etc.

Loads operating system kernel and starts execution

Wait for an event to happen

Event: an interrupt from either hardware or
software
Operating System Concepts Essentials – 9th Edition
1.9
Silberschatz, Galvin and Gagne ©2013
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
Operating System Concepts Essentials – 9th Edition
1.10
Silberschatz, Galvin and Gagne ©2013
CPU
 Fetch-decode-execute cycle
1.
Fetch an instruction from the memory
2.
Decode the instruction (determine its type and operands)
3.
Fetch operand from memory (if necessary)
4.
Execute

Pipelined

Superscalar CPU

Multicore chips: CPU chips with multiple processors (cores) on them
Operating System Concepts Essentials – 9th Edition
1.11
Silberschatz, Galvin and Gagne ©2013
Registers
 Inside the CPU
 General (Data) Registers: hold temporary results

LOAD from memory to register

STORE from register to memory

ADD two operands (memory/register)
 Program Counter (PC)

holds the memory address of the next instruction to be fetched

incremented after each instruction
 Stack Pointer (SP): top of the current stack in memory
 PSW (Flags register)

Keeps control bits, flags set by instructions

Such as result of last comparison or mode: kernel or user
Operating System Concepts Essentials – 9th Edition
1.12
Silberschatz, Galvin and Gagne ©2013
Storage Hierarchy
 Storage systems organized in hierarchy

Speed/Access time

Cost/Capacity

Volatility
Operating System Concepts Essentials – 9th Edition
1.13
Silberschatz, Galvin and Gagne ©2013
Storage Definitions and Notation Review
The basic unit of computer storage is the bit. A bit can contain one of two
values, 0 and 1. All other storage in a computer is based on collections of bits.
Given enough bits, it is amazing how many things a computer can represent:
numbers, letters, images, movies, sounds, documents, and programs, to name
a few. A byte is 8 bits, and on most computers it is the smallest convenient
chunk of storage. For example, most computers don’t have an instruction to
move a bit but do have one to move a byte. A less common term is word,
which is a given computer architecture’s native unit of data. A word is made up
of one or more bytes. For example, a computer that has 64-bit registers and 64bit memory addressing typically has 64-bit (8-byte) words. A computer executes
many operations in its native word size rather than a byte at a time.
Computer storage, along with most computer throughput, is generally measured
and manipulated in bytes and collections of bytes.
A kilobyte, or KB, is 1,024 bytes
a megabyte, or MB, is 1,0242 bytes
a gigabyte, or GB, is 1,0243 bytes
a terabyte, or TB, is 1,0244 bytes
a petabyte, or PB, is 1,0245 bytes
Computer manufacturers often round off these numbers and say that a
megabyte is 1 million bytes and a gigabyte is 1 billion bytes. Networking
measurements are an exception to this general rule; they are given in bits
(because networks move data a bit at a time).
Operating System Concepts Essentials – 9th Edition
1.14
Silberschatz, Galvin and Gagne ©2013
Storage-Device Hierarchy
Operating System Concepts Essentials – 9th Edition
1.15
Silberschatz, Galvin and Gagne ©2013
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
Operating System Concepts Essentials – 9th Edition
1.16
Silberschatz, Galvin and Gagne ©2013
Registers and Cache
 Registers: in CPU, fastest, volatile
 Cache (possible multiple levels):

keeps most accessed memory words

Close to or on CPU

volatile
Operating System Concepts Essentials – 9th Edition
1.17
Silberschatz, Galvin and Gagne ©2013
Main Memory
 Main memory – only large storage media that the CPU can access
directly

Random access (also called RAM)

Typically volatile
Operating System Concepts Essentials – 9th Edition
1.18
Silberschatz, Galvin and Gagne ©2013
Secondary Storage

Hard Disk: extension of main memory that provides large nonvolatile storage capacity

One or more metal or glass platters covered with magnetic recording material,
rotating

A mechanical arm, attached to it heads to read/write per surface

Data is written in concentric circles—tracks

Cylinder: set of tracks at the same position of every platter

Each track is divided into sectors (smallest unit that can be read/written, typically
512 bytes per sector)

Seek time: moving arm to desired track

Rotational delay: time for the desired sector to rotate under head
Operating System Concepts Essentials – 9th Edition
1.19
Silberschatz, Galvin and Gagne ©2013
Secondary Storage
 Solid-state disks:

faster than hard disks, nonvolatile

Various technologies

Becoming more popular
 Magnetic Tape:

back up for disk storage, nonvolatile

Needs to be forwarded to get to the requested block, takes minutes

Cheap and removable
Operating System Concepts Essentials – 9th Edition
1.20
Silberschatz, Galvin and Gagne ©2013
Special memory Devices
 ROM: Read Only Memory

Small, nonvolatile, comes with computer

Low level software, bootstrap loader
 EEPROM and flash RAM: erasable and rewritable, used similar to ROM
 CMOS: volatile, but has its own battery

Keeps time and date, some config parameters uch as which disk to boot
from.
Operating System Concepts Essentials – 9th Edition
1.21
Silberschatz, Galvin and Gagne ©2013
I/O Devices
 I/O Device has two parts

Controller

The device itself
 Controller

Accepts commands from OS to control the device.

Provides a simpler interface to OS

E.g. controller accepts a read command 11,206 from disk 2, and
converts this linear sector number to cylinder, sector, and head
Operating System Concepts Essentials – 9th Edition
1.22
Silberschatz, Galvin and Gagne ©2013
I/O Devices
 Device Driver:

The software that talks to the controller, giving commands, accepting
responses

Controller manufacturers supply it with the controller

Driver has to be put into kernel

Relink with kernel and reboot (older UNIX systems)

Make an entry that tells OS it needs a driver and reboot
–

At boot time OS finds and loads the driver (Windows)
Getting more and more common: dynamic loading
–
While running OS can install drivers without reboot
–
E.g. USB
Operating System Concepts Essentials – 9th Edition
1.23
Silberschatz, Galvin and Gagne ©2013
I/O Structure
 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
Operating System Concepts Essentials – 9th Edition
1.24
Silberschatz, Galvin and Gagne ©2013
I/O Structure
Three different ways of I/O
(1) Busy Waiting:
 user program issues a system call
 Kernel translates into a procedure call to the appropriate driver
 The driver starts the I/O and
 Loops to continuously poll the device if it is done
 When I/O is complete driver puts the data where needed and returns to OS
 OS returns the control to caller
 DISADVANTAGE: wait loop ties the CPU until I/O is finished
 At most one I/O request is outstanding at a time, no simultaneous I/O
processing
(2) Interrupt Driven I/O
 Driver starts I/O and asks the device to give an interrupt when it is finished
 Driver returns to OS
 OS blocks the program waiting for I/O, and looks for other work
 When controller detects end of transfer it generates an interrupt
Operating System Concepts Essentials – 9th Edition
1.25
Silberschatz, Galvin and Gagne ©2013
Common Functions of Interrupts
 When the CPU is interrupted, stops what it is doing
 transfers control to the interrupt service routine (part of
the driver for the interrupting device
 The interrupt service routine executes
 On completion, CPU resumes execution

Interrupt architecture must save the address of the
interrupted instruction
Operating System Concepts Essentials – 9th Edition
1.26
Silberschatz, Galvin and Gagne ©2013
Interrupt Timeline
Operating System Concepts Essentials – 9th Edition
1.27
Silberschatz, Galvin and Gagne ©2013
Interrupt Handling
 The operating system preserves the state of the CPU by
storing the registers and the program counter
 Determines which interrupt service routine has to run:
 Has to do this quickly

A table of pointers to interrupt service routines for each
possible interrupt (called interrupt routine table or
interrupt vector)
 Stored in low memory (first hundred and so locations)

Indexed by unique device number of the interrupting
device
 After the interrupt is serviced, the saved return address is
loaded to the PC and execution resumes
 Interrupt service routines: Separate segments of code
determine what action should be taken for each type of
interrupt
Operating System Concepts Essentials – 9th Edition
1.28
Silberschatz, Galvin and Gagne ©2013
I/O Structure
(3) DMA (Direct Memory Access):

Interrupt-driven I/O is fine for small data transfers,
but has high overhead for large amounts of data
transfer

DMA: Device controller transfers blocks of data
from buffer storage directly to main memory without
CPU intervention

Done by a DMA chip


CPU sets up the DMA chip telling how many
bytes to transfer, the device and memory
addresses involved and lets it go
Only one interrupt is generated by DMA per block,
rather than the one interrupt per byte
Operating System Concepts Essentials – 9th Edition
1.29
Silberschatz, Galvin and Gagne ©2013
How a Modern Computer Works
A von Neumann architecture
Operating System Concepts Essentials – 9th Edition
1.30
Silberschatz, Galvin and Gagne ©2013
Computer-System Architecture
 Most systems use a single general-purpose processor

Most systems have special-purpose processors as well
 Multiprocessors systems growing in use and importance

Also known as parallel systems, tightly-coupled systems

Advantages include:
1.
Increased throughput (more work in less time)
2.
Economy of scale (cheaper than multiple single processor
systems, sharing resources)
3.
Increased reliability – fault tolerance: suffer failure of a single
component but still continue operation
Operating System Concepts Essentials – 9th Edition
1.31
Silberschatz, Galvin and Gagne ©2013
Computer-System Architecture
 Two types of Multiprocessor Systems:
1.
Asymmetric Multiprocessing – each processor is assigned a specific
task. Boss/worker relationship.
2.
Symmetric Multiprocessing (SMP)– each processor performs all tasks
Peer relationship.
Operating System Concepts Essentials – 9th Edition
1.32
Silberschatz, Galvin and Gagne ©2013
Symmetric Multiprocessing Architecture
Operating System Concepts Essentials – 9th Edition
1.33
Silberschatz, Galvin and Gagne ©2013
A Dual-Core Design
 Multicore design

Multiple processors on a single chip

Faster communication between CPUs

Less power than multiple chips
Operating System Concepts Essentials – 9th Edition
1.34
Silberschatz, Galvin and Gagne ©2013
Clustered Systems
 Like multiprocessor systems, but multiple systems working together

Usually sharing storage via a storage-area network (SAN)

Provides a high-availability service which survives failures

Some clusters are for high-performance computing (HPC)


Applications must be written to use parallelization
Some have distributed lock manager (DLM) to avoid conflicting
operations

E.g. multiple machines having full access to the data in the shared
database
Operating System Concepts Essentials – 9th Edition
1.35
Silberschatz, Galvin and Gagne ©2013
Clustered Systems
Operating System Concepts Essentials – 9th Edition
1.36
Silberschatz, Galvin and Gagne ©2013
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

Switching from one job to another: context switch

Response time should be short

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
Operating System Concepts Essentials – 9th Edition
1.37
Silberschatz, Galvin and Gagne ©2013
Memory Layout for Multiprogrammed System
Operating System Concepts Essentials – 9th Edition
1.38
Silberschatz, Galvin and Gagne ©2013
Download