Download Chapter 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

DNIX wikipedia , lookup

Object storage wikipedia , lookup

Mobile operating system wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

RSTS/E wikipedia , lookup

Security-focused operating system wikipedia , lookup

Burroughs MCP wikipedia , lookup

Copland (operating system) wikipedia , lookup

Spring (operating system) wikipedia , lookup

Unix security wikipedia , lookup

Distributed operating system wikipedia , lookup

Process management (computing) wikipedia , lookup

VS/9 wikipedia , lookup

CP/M wikipedia , lookup

Paging wikipedia , lookup

Transcript
Chapter 1: Introduction
 Overview

What Operating Systems Do

Computer-System Organization and Architecture

Operating-System Structure and Operations

Process Management

Memory Management

Storage Management

Protection and Security

File Systems
Operating System Concepts
1.1
Silberschatz, Galvin and Gagne ©2005
Computer System Structure
 Computer system can be divided into four components

Hardware – provides basic computing resources


Operating system


Controls and coordinates use of hardware among various
applications and users
Application programs – define the ways in which the system
resources are used to solve the computing problems of the
users


CPU, memory, I/O devices
Word processors, compilers, web browsers, database
systems, video games
Users

Operating System Concepts
People, machines, other computers
1.2
Silberschatz, Galvin and Gagne ©2005
Four Components of a Computer System
Operating System Concepts
1.3
Silberschatz, Galvin and Gagne ©2005
What is an Operating System ?
 OS is a resource allocator

Manages all resources such as CPU, memory, file system, etc

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
 No universally accepted definition

“Everything a vendor ships when you order an operating system” is good
approximation
Operating System Concepts
1.4
Silberschatz, Galvin and Gagne ©2005
Computer System Organization
 Computer-system operation

One or more CPUs and device controllers connect through
common bus providing access to shared memory

Concurrent execution of CPUs and devices competing for
memory cycles
Operating System Concepts
1.5
Silberschatz, Galvin and Gagne ©2005
Computer-System Operation







I/O devices and the CPU can execute concurrently.
Each device controller is in charge of a particular device type.
 Depending on the device controller, there may be more than one attached device. For example
seven or more devices can be attached to a SCSI (small computer system interface) controller.
Each device controller maintains local buffer storage and a set of special purpose registers
Typically, operating systems have a device driver for each device controller.
 To start an I/O, the device driver loads the appropriate registers within the device driver.
 The device controller, in turn, examines the contents of these registers and performs the required
operation (e.g, read a character from Key board, read from a file, etc). This is called Programmed
I/O (PIO).
 Many computers avoid burdening the main CPU with PIO by offloading some of this work to a
special-purpose processor called a direct-memory-access (DMA) controller (details in chapter
13).
CPU moves data from/to main memory to/from local buffers of the device controllers
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 .
Operating System Concepts
1.6
Silberschatz, Galvin and Gagne ©2005
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.
 Incoming interrupts are disabled while another interrupt is being
processed to prevent a lost interrupt.
 A trap is a software-generated interrupt caused either by an error
or a user request.
 An operating system is interrupt driven.
Operating System Concepts
1.7
Silberschatz, Galvin and Gagne ©2005
Interrupt Handling
 Interrupt handling:

The operating system saves 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
Operating System Concepts
1.8
Silberschatz, Galvin and Gagne ©2005
Interrupt Timeline
Operating System Concepts
1.9
Silberschatz, Galvin and Gagne ©2005
I/O Structure
 Blocking I/O (Synchronous): 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.
 Non-blocking I/O (Asynchronous): After I/O starts, control
returns to user program without waiting for I/O completion.
.
Operating System Concepts
1.10
Silberschatz, Galvin and Gagne ©2005
Two I/O Methods
Synchronous
Operating System Concepts
Asynchronous
1.11
Silberschatz, Galvin and Gagne ©2005
Storage Structure
 Main memory – only large storage media that the CPU can access
directly.
 Secondary storage – extension of main memory that provides large
nonvolatile storage capacity.

Magnetic 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.
Operating System Concepts
1.12
Silberschatz, Galvin and Gagne ©2005
Storage Hierarchy
 Storage systems organized in hierarchy.

Speed

Cost

Volatility
 Caching – copying information into faster storage system; main
memory can be viewed as a last cache for secondary storage.
Operating System Concepts
1.13
Silberschatz, Galvin and Gagne ©2005
Storage-Device Hierarchy
Here, electronic disk could refer to flash memory chips used by solid sate
drives
Operating System Concepts
1.14
Silberschatz, Galvin and Gagne ©2005
Computer System Structure
 Single processor systems

Have one main CPU capable of executing general purpose
instructions (almost all systems come with special purpose
CPUs. E.g disk controller microprocessor)
 Multiprocessor systems (parallel systems, multicore systems)

Main advantages: Increased throughput, economy of scale,
increased reliability.

Disadvantages: Need to write programs which take advantage
of the multiprocessors
 Clustered systems – loosely coupled systems

A type of multiprocessor system in which CPUs are clustered
into groups and share storage and are linked via local area
networks or faster interconnect such as Infiniband.
Operating System Concepts
1.15
Silberschatz, Galvin and Gagne ©2005
Operating System Structure


Multiprogramming needed for efficiency

Single program cannot keep CPU and I/O devices busy at all times

Multiprogramming increases CPU utilization by organizing 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), the CPU switches to another job
Timesharing (multitasking) is logical extension of multiprogramming in which CPU
switches jobs so frequently that users can interact with each job while it is running, creating
interactive computing (e.g., a lawyer doesn’t work on one case at a time)

Response time should be short. Typically less than a second

A program loaded into memory and executing is called a process

If several jobs are ready to run at the same time, we need CPU scheduling

To ensure reasonable response time and prevent thrashing, swapping moves
processes in and out of memory.

Virtual memory allows execution of processes that cannot not fit completely in memory
Operating System Concepts
1.16
Silberschatz, Galvin and Gagne ©2005
Memory Layout for Multiprogrammed System
Operating System Concepts
1.17
Silberschatz, Galvin and Gagne ©2005
Operating-System Operations
 Modern Operating systems are Interrupt driven.
 Software error or request creates exception or trap

E.g., Division by zero, invalid memory access, or a specific request from an
user program for operating-system service

Other process problems include infinite loop, processes modifying each others
address space or the operating system
 Dual-mode operation allows OS to protect itself and other system components
 User mode and kernel mode (system mode, supervisor mode, etc.)
 A bit called Mode bit added to the hardware to indicate current mode
Provides ability to distinguish whether the system is running user code or
kernel code
 Some instructions designated as privileged, are only executable in kernel
mode
 System call changes mode to kernel, return from system call resets it to
user
 CPUs that support virtualization may have a separate mode to indicate when
the Virtual machine manager (VMM) is in control of the system

Operating System Concepts
1.18
Silberschatz, Galvin and Gagne ©2005
Transition from User to Kernel Mode
Operating System Concepts
1.19
Silberschatz, Galvin and Gagne ©2005
Process Management

A process is a program in execution. Program is a passive entity, process is
an active entity.

Process needs resources to accomplish its task

CPU, memory, I/O, files

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

A Multi-threaded process has one program counter per thread

Typically system has many processes, some user processes, some
operating system processes running concurrently on one or more CPUs

Concurrency is achieved by multiplexing the CPUs among the
processes / threads
Operating System Concepts
1.20
Silberschatz, Galvin and Gagne ©2005
Process Management Activities
The operating system is responsible for the following activities in
connection with process management:
 Scheduling processes and threads to CPUs
 Creating and deleting both user and system processes
 Suspending and resuming processes
 Providing mechanisms for process synchronization
 Providing mechanisms for process communication
Operating System Concepts
1.21
Silberschatz, Galvin and Gagne ©2005
Memory Management
 All data reside in memory before and after processing
 All instructions for execution reside in memory before execution.
 Memory management determines what is in memory and when
 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
Operating System Concepts
1.22
Silberschatz, Galvin and Gagne ©2005
Storage Management
 OS provides uniform, logical view of information storage

Abstracts physical properties to logical storage unit - file
 Each medium is controlled by a device driver (i.e., disk drive, tape
drive)
 Varying properties include access speed, capacity, datatransfer rate, access method (sequential or random)
 File-System management
 Files are usually organized into directories
 Access control 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

Operating System Concepts
1.23
Silberschatz, Galvin and Gagne ©2005
Mass-Storage Management

Usually disks are used to store data that do not fit in main memory or data
that must be kept for a “long” period of time.

Proper management of storage is of central importance

Entire speed of computer operation hinges on disk subsystem and the
algorithms used.

OS activities related to disk management


Free-space management

Storage allocation

Disk scheduling
Some storage need not be fast

Tertiary storage includes optical storage, magnetic tape

Still must be managed

Varies between WORM (write-once, read-many-times) and RW (readwrite)
Operating System Concepts
1.24
Silberschatz, Galvin and Gagne ©2005
Caching
 Important principle, performed at many levels in a computer (in
hardware, operating system, software)
 Information in use is copied from slower to faster storage
temporarily
 Faster storage (cache) is checked first to determine if information is
there

If it is, the information used directly from the cache (fast)

If not, data copied to cache and used there
 Cache is smaller than storage being cached

Cache management is an important design problem

Cache size and cache replacement policy – algorithms for that
Operating System Concepts
1.25
Silberschatz, Galvin and Gagne ©2005
I/O Subsystem
 One purpose of OS is to hide peculiarities of specific hardware
devices from the user
 I/O subsystem consists of several components

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)

A General device-driver interface

Drivers for specific hardware devices
Operating System Concepts
1.26
Silberschatz, Galvin and Gagne ©2005
Protection and Security
 Protection – any mechanism for controlling access of processes or users to
resources.
 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) include name and associated number, one per user
 User ID is 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 users to change to effective UID with more rights
for an activity.
Operating System Concepts
1.27
Silberschatz, Galvin and Gagne ©2005
Distributed systems
 A collection of computers connected by a communication network
to provide the users with access to the various resources the
system maintains
 Advantages of distributed systems

Resource sharing

Fault-tolerance

Increased throughput

Low cost…
Operating System Concepts
1.28
Silberschatz, Galvin and Gagne ©2005
Computing Environments
 Traditional computing

Blurring over time

Office environment
 Then:
PCs connected to a network, terminals attached
to mainframe or minicomputers providing support for
batch and timesharing jobs
 Now:
portals allowing networked and remote systems
access to same resources

Home networks
 Used
 Now
Operating System Concepts
to be single systems, then came modems
firewalled, networked
1.29
Silberschatz, Galvin and Gagne ©2005
Computing Environments (Cont.)

Client-Server Computing
 Dumb terminals supplanted by smart PCs
 Many systems are now servers, responding to requests generated
by clients
 Compute-server provides an interface to client to request
services (i.e., database)
 File-server provides interface for clients to store and retrieve
files
Operating System Concepts
1.30
Silberschatz, Galvin and Gagne ©2005
Peer-to-Peer Computing
 Another model of distributed system
 P2P does not distinguish clients and servers

Instead all nodes are considered peers

Each may 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
Operating System Concepts
1.31
Silberschatz, Galvin and Gagne ©2005
Virtualization and Cloud Computing
 Virtualization is a technology that allows operating systems to run as applications
within other operating systems
 Cloud Computing allows vendors to deliver computing, storage and even
applications as a service across a network. It uses virtualization as a base for
functionality.
 Some types of cloud computing are:

Public cloud : a cloud available via the Internet to anyone willing to pay for the
services

Private cloud: A cloud run by a company for that company’s own use

Hybrid cloud : a cloud that has both public and private components.

Software as a service (SaaS): One or more applications (such as word
processor, spreadsheets) available via Internet

Platform as a Service (PaaS): a software stack ready for applications use via
Internet(for example, a database server)

Infrastructure as a service (IaaS): Servers or storage available over Internet.
Operating System Concepts
1.32
Silberschatz, Galvin and Gagne ©2005
Real time embedded systems
 Embedded systems

These devices are most prevalent form of
computers in existence. They can be found in
car engines, microwave ovens, robots, VCRs,
sensors, ….
 These devices are designed to perform specific
tasks and the operating systems designed for
such devices usually provide limited features
 Embedded systems almost always run realtime operating systems
Real-time systems have well-defined fixed
time constraints
Operating System Concepts
1.33
Silberschatz, Galvin and Gagne ©2005