chapter 1: introductioncse.snu.ac.kr/scsc/sites/default/files/운영체제의... · 2018. 8....
Post on 24-Feb-2021
2 Views
Preview:
TRANSCRIPT
Silberschatz, Galvin and Gagne 2010 1.1
Chapter 1: Introduction
What Operating Systems Do
Computer-System Organization
Operating-System Structure and Operations
Process Management
Memory and Storage Management
Protection and Security
Distributed Systems
Special-Purpose Systems
Silberschatz, Galvin and Gagne 2010 1.2
Objectives
To provide a grand tour of the major operating systems
components
To provide coverage of basic computer system
organization
Silberschatz, Galvin and Gagne 2010 1.3 Operating System Concepts
What is an Operating System?
A program that acts as an intermediary between
a user and the computer hardware.
Operating system goals:
Execute user programs
Make solving user problems easier.
Make the computer system convenient to use.
Use hardware in an efficient manner.
“Performance”
Throughput --- jobs / sec. system oriented
Utilization --- % of time busy system oriented
Response time --- sec / job user oriented
user oriented index conflicts with system oriented indices
User
OS
HW
Other Programs
OS
Hardware
Silberschatz, Galvin and Gagne 2010 1.4 Operating System Concepts
Computer System Components
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, games, business programs).
4. Users
(people, machines, other computers).
Other Programs
OS
Hardware
Silberschatz, Galvin and Gagne 2010 1.5 Operating System Concepts
Abstract View of System Components
Other Programs
OS
Hardware
Silberschatz, Galvin and Gagne 2010 1.6 Operating System Concepts
Operating System Definitions
Definition 1 -- Resource allocator
manages and allocates resources.
Definition 2 -- Control program
controls the execution of user programs and operations of
I/O devices
.
Definition 3 -- Kernel
one program running at all times
memory resident all the time
all else depend on this program.
Other Programs
OS
Hardware
Silberschatz, Galvin and Gagne 2010 1.7
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
Silberschatz, Galvin and Gagne 2010 1.8
Computer Startup
bootstrap program is loaded at power-up or reboot
Typically stored in ROM or EEPROM, generally known as
firmware
Initializates all aspects of system
Loads operating system kernel and starts execution
Silberschatz, Galvin and Gagne 2010 1.9 Operating System Concepts
Computer-System Operation
I/O devices and the CPU can execute concurrently.
Each I/O device controller
is in charge of a particular device type. (control reg, status reg.)
has a local buffer. (data register)
CPU moves data from/to main memory to/from local buffers
I/O is from the device to local buffer.
Device controller informs CPU that it has finished its operation
by causing an interrupt.
memory
Silberschatz, Galvin and Gagne 2010 1.10 Operating System Concepts
Interrupt
enable, disable Intr.
PC←PC+4
Interrupt request bit
Instr. fetch
Instr. decode
Execution
Read data
Write Back
PC ← address of
interrupt handler
Save register
CPU
I’m Done
Next I/O
Please
PC: Program Counter Register
main()
----------
----------
----------
do-I/O;
----------
----------
----------
----------
----------
----------
----------
Intrp_handler()
-----------------
-----------------
-----------------
-----------------
-----------------
Silberschatz, Galvin and Gagne 2010 1.11 Operating System Concepts
PC←PC+4
Interrupt request bit
Instr. fetch
Instr. decode
Execution
Read data
Write Back
PC ← address of
interrupt handler
Save register
CPU
Various
devices
PC: Program Counter Register
main()
----------
----------
----------
do-I/O;
----------
----------
----------
----------
----------
----------
----------
Intrp_handler()
-----------------
disk:-----------
-----------------
-----------------
mouse:--------
-----------------
-----------------
printer:---------
-----------------
-----------------
Silberschatz, Galvin and Gagne 2010 1.12 Operating System Concepts
Interrupt Vector
INTerrupt
Request
(INTR)
PC←PC+4
Interrupt bit set?
Instr. fetch
Instr. decode
Execution
Memory
Write Back
NO
PC
Intrp_Vector[Dev Code]
Save register
YES
CPU
Device
Code
main()
----------
----------
----------
do-I/O();
----------
----------
----------
----------
----------
----------
----------
Intrp_tty()
-----------------
-----------------
-----------------
-----------------
-----------------
Intrp_disk()
-----------------
-----------------
-----------------
-----------------
-----------------
Intrp_mouse()
-----------------
-----------------
-----------------
-----------------
-----------------
Silberschatz, Galvin and Gagne 2010 1.13 Operating System Concepts
Interrupt v.s. Trap(Exception)
enable, disable Intr.
PC←PC+4
Interrupt request bit
Instr. fetch
Instr. decode
Execution
Read data
Write Back
PC ← address of
interrupt handler
Save register
CPU
Exception
illegal address
illegal opcode
divide by zero
Silberschatz, Galvin and Gagne 2010 1.14 Operating System Concepts
Interrupts vs. Trap(exception)
Interrupt Exception
Cause: external to CPU Cause: CPU internal - while
executing current instruction
eg I/O devices, timer eg Programming error
Anomalous conditions
Current instruction completes Current instruction
may not complete
Asynchronous to clock Synchronous to clock
Silberschatz, Galvin and Gagne 2010 1.15 Operating System Concepts
Common Functions of Interrupt handling
Interrupts transfer control to the interrupt service routine(ISR)
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.
operating system is interrupt driven.
Device interrupt
code vector pointers
ISR
ISR
O S “2nd
Device Interrupts”
700
Silberschatz, Galvin and Gagne 2010 1.16 Operating System Concepts
Interrupt Handling
1.The operating system preserves the state of the CPU
by storing registers and the program counter.
2. Determines which type of interrupt has occurred by:
polling or
vectored interrupt (HW provides code)
3. Separate segments of code determine what action
should be taken for each type of interrupt
(ISR: Interrupt Service Routine)
Device interrupt
code vector pointers
ISR
ISR
O S disk
network
mouse
1.17 Silberschatz, Galvin and Gagne © 2005 Operating System Concepts
Interrupt Timeline
1.18 Silberschatz, Galvin and Gagne © 2005 Operating System Concepts
Direct Memory Access (DMA)
Structure
High-speed I/O devices such as disks are
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.
Instead of interrupting every byte interrupt once when the
whole has been moved
CPU
memory
device
CPU involves in every data word movement?
CPU (central CPU) is too expensive for every byte I/O
I/O does not need BIG CPU, many complex instructions
store data
inc address small specialized (I/O purpose) CPU
loop test
DMA
1.19 Silberschatz, Galvin and Gagne © 2005 Operating System Concepts
Computer System Architecture
Single-Processor system.
Multiprocessor system.
Increased throughput
Economy of scale
Increased reliability
Symmetric vs. Asymmetric multiprocessing
Multi-core chip
Clustered system
High availability
1.20 Silberschatz, Galvin and Gagne © 2005 Operating System Concepts
Operating System Structure
Multiprogramming 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
Silberschatz, Galvin and Gagne 2010 1.21 Operating System Concepts
Memory Layout for a Single User System
Monitor
I/O was slower than CPU
While I/O is in progress
CPU was idle
But CPU was expensive
1.22 Silberschatz, Galvin and Gagne © 2005 Operating System Concepts
Memory Layout for Multiprogrammed
System
CPU + Tape
CPU +
CPU
Network
Silberschatz, Galvin and Gagne 2010 1.23 Operating System Concepts
OS Features Needed for Multiprogramming
I/O routine supplied by the system.
Memory management –
the system must allocate the memory to several jobs.
Size of allocation , …
CPU scheduling –
must choose among several jobs ready to run on CPU
Allocation of devices.
Silberschatz, Galvin and Gagne 2010 1.24 Operating System Concepts
Time-Sharing Systems–Interactive Computing
(multi-user system)
CPU is multiplexed among several jobs (batch-gcc-batch-mail-…)
Users are given illusion that he is using the whole system(interactive).
when the operating system finishes the execution of one command,
OS asks next “control statement” from the user’s keyboard.
Eg ppt, word, ….
Telephone
bill
gcc
Windows
UNIX
Linux
1.25 Silberschatz, Galvin and Gagne © 2005 Operating System Concepts
Operating System Structure
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
Silberschatz, Galvin and Gagne 2010 1.26
Operating-System Operations
Interrupt driven by hardware
Software error or request creates exception or trap
Division by zero, request for operating system service
Other process problems include infinite loop, processes modifying each other or the operating system
Silberschatz, Galvin and Gagne 2010 1.27
Operating-System Operations
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
Silberschatz, Galvin and Gagne 2010 1.28 Operating System Concepts
Dual-Mode Operation
Sharing system resources requires operating system to ensure
that an incorrect program cannot cause other programs to
execute incorrectly.
Provide hardware support to differentiate between at least two
modes of operations.
1. User mode – execution done on behalf of a user.
2. Kernel mode (or monitor-supervisor-system mode)
– execution done on behalf of operating system.
Silberschatz, Galvin and Gagne 2010 1.29 Operating System Concepts
Dual-Mode Operation (Cont.)
Mode bit added to computer hardware to indicate the
current mode: kernel (0) or user (1).
When an interrupt or fault occurs hardware switches
to kernel(or protection) mode.
Privileged instructions can be used only in kernel mode.
Kernel
(OS) user
Interrupt / fault
CPU sets this bit
OS sets to user mode
Silberschatz, Galvin and Gagne 2010 1.30
Mode Transition
Silberschatz, Galvin and Gagne 2010 1.31 Operating System Concepts
I/O Protection
All I/O instructions are privileged instructions.
Must ensure that a user program could never gain control of the computer in monitor mode
Given the I/O instructions are privileged, how does the user
program perform I/O?
System call – user process requests I/O action to OS Usually takes the form of a trap to a specific location in the interrupt
vector.
Control passes through the interrupt vector to
a (trap or system call) service routine in the OS,
and the mode bit is set to monitor mode by interrupt HW.
The monitor verifies that the parameters are correct and legal, executes the I/O request,
and returns control to the instruction following the system call.
Silberschatz, Galvin and Gagne 2010 1.32 Operating System Concepts
I/O – only by system call
My a.out (parameters)
chmodk
Kernel a.out
trap
user_mode Kernel read( ) checks permission first
sys call
system
call
invocation
“change mode to kernel” is privileged instrucion
and is not allowed in user mode
trap()
read()
Silberschatz, Galvin and Gagne 2010 1.33 Operating System Concepts
Use of a System Call to Perform I/O
sys call
handler
Silberschatz, Galvin and Gagne 2010 1.34 Operating System Concepts
CPU Protection
Timer – interrupts computer after specified period to
ensure operating system maintains control.
Timer to prevent infinite loop / process hogging resources
Timer is decremented every clock tick.
When timer reaches the value 0, an interrupt occurs.
Timer is commonly used to implement time sharing.
Timer is also used to compute the current time.
Load-timer is a privileged instruction.
Silberschatz, Galvin and Gagne 2010 1.35
Process Management
A process is a program in execution. It is a unit of work within the system.
Program is a passive entity,
process is an active entity. Process needs resources to accomplish its task
CPU, memory, I/O, files
Initialization data Process termination requires reclaim of any reusable
resources
Silberschatz, Galvin and Gagne 2010 1.36
Process Management
Single-threaded process has one program counter
Process executes instructions sequentially, one at a time, until completion
Multi-threaded process has one program counter per thread
Typically system has many processes, some user, some operating system running concurrently on one or more CPUs
Concurrency by multiplexing the CPUs among the processes / threads
Silberschatz, Galvin and Gagne 2010 1.37
Process Management Activities
The operating system is responsible for the following
activities in connection with process management:
Creating and deleting both user and system processes
Suspending and resuming processes
Providing mechanisms for process synchronization
Providing mechanisms for process communication
Providing mechanisms for deadlock handling
Silberschatz, Galvin and Gagne 2010 1.38
Memory Management
All data in memory before and after processing
All instructions in memory in order to execute
Memory management determines what is in memory
when
Optimizing CPU utilization and computer response to users
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
Silberschatz, Galvin and Gagne 2010 1.39
Storage Management
OS provides uniform, logical view of information storage
Abstracts physical properties to logical storage unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include
– access speed,
– capacity,
– data-transfer rate,
– access method (sequential or random)
Silberschatz, Galvin and Gagne 2010 1.40
File System Management
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
Silberschatz, Galvin and Gagne 2010 1.41
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 depends 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
Varies between WORM (write-once, read-many-times) and
RW (read-write)
Silberschatz, Galvin and Gagne 2010 1.42
Performance of Various Storage
Movement between levels of storage hierarchy can be
explicit or implicit
Silberschatz, Galvin and Gagne 2010 1.43
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
Silberschatz, Galvin and Gagne 2010 1.44
Protection and Security
Protection – any mechanism for controlling access 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
Silberschatz, Galvin and Gagne 2010 1.45
Protection and Security
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
Silberschatz, Galvin and Gagne 2010 1.46 Operating System Concepts
Many CPU
Tightly Coupled Loosely Coupled
Bus
(share clock, memory)
Board, Room
Network
Campus, Building, City
Parallel
Processing Multi-
Processing
Distributed
Processing
Network
Operating
System
P
CPU
CPU
CPU
CPU
P CPU
CPU
CPU
CPU
P
P
P
User/Program network
aware
User/Program
Not aware
of network
Silberschatz, Galvin and Gagne 2010 1.47 Operating System Concepts
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
communication lines,
such as high-speed buses or telephone lines.
Advantages of distributed systems.
Resources Sharing
illusion that there is only one OS
Computation speed up – load sharing
Reliability
Communications
Silberschatz, Galvin and Gagne 2010 1.48 Operating System Concepts
Distributed Systems (cont)
Requires networking infrastructure.
Local area networks (LAN) or Wide area networks (WAN)
Network Operating System
Different from distributed system
Each node (processor + OS) is autonomous
Aware of network
Silberschatz, Galvin and Gagne 2010 1.49 Operating System Concepts
Parallel Systems
Multiprocessor system: Many CPU’s 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 (# of jobs / second)
Economical
Increased reliability
graceful degradation
fail-soft systems (fault tolerance – fault avoidance)
Terminology fault -- flaw, defect, wrong action itself
error – result of fault
Silberschatz, Galvin and Gagne 2010 1.50 Operating System Concepts
Parallel Systems (Cont.)
Symmetric multiprocessing (SMP)
Each processor runs 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 allocates work to slave processors.
More common in extremely large systems
Silberschatz, Galvin and Gagne 2010 1.51 Operating System Concepts
Real-Time Systems
Rigid response time requirement (milli-seconds or faster)
Eg: missile control, medical equipment control system.
sensor
system computer
control
Deadline -- either hard or soft real-time.
Hard realtime must - atomic power plant
Soft realtime best effort - MP3 player, …
eg Robot
Missle
Atomic power plant
Silberschatz, Galvin and Gagne 2010 1.52 Operating System Concepts
Real-Time Systems (Cont.)
Hard real-time:
Secondary storage limited or absent
(disk access time is not predictable)
data stored in memory
OS has to be different
(other OS -- no response time guarantee)
general-purpose operating systems.
Timesharing Systems
Soft real-time
Limited utility in industrial control of robotics
Useful in some applications (multimedia, virtual reality) .
Silberschatz, Galvin and Gagne 2010 1.53 Operating System Concepts
Handheld Systems
Personal Digital Assistants (PDAs)
Cellular telephones
Issues:
Limited memory
Small display screens
Limited power
Slow processors
Smartphone
Silberschatz, Galvin and Gagne 2010 1.54 Operating System Concepts
Desktop (PC) Systems
Personal computers
computer system dedicated to a single user.
I/O devices
keyboards, mice, display screens, personal printer
(from old system’s card readers, shared line printers)
Goal change:
From Maximum hardware utilization
To User convenience and responsiveness (Single user).
Do not need protection (Single user system)
Among users
Among user and system (minimum system is in ROM)
Vulnerable to worm, virus, etc.
PC operating systems (Windows, MacOS, Linux)
Silberschatz, Galvin and Gagne 2010 1.55
Computing Environments
Traditional computer
Blurring over time
Office environment
PCs connected to a network, terminals attached to
mainframe or minicomputers providing batch and
timesharing
Now portals allowing networked and remote systems
access to same resources
Home networks
Used to be single system, then modems
Now firewalled, networked
Silberschatz, Galvin and Gagne 2010 1.56
Computing Environments (Cont.)
Client-Server Computing
Dumb terminals supplanted by smart PCs
Many systems 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
Silberschatz, Galvin and Gagne 2010 1.57
Peer-to-Peer Computing
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
Silberschatz, Galvin and Gagne 2010 1.58
Web-Based Computing
Web has become ubiquitous
PCs most prevalent devices
More devices becoming networked to allow web access
New category of devices to manage web traffic among
similar servers: load balancers
Use of operating systems like Windows 95, client-side,
have evolved into Linux and Windows XP, which can be
clients and servers
Cloud computing
Silberschatz, Galvin and Gagne 2010 1.59
Silberschatz, Galvin and Gagne 2010 1.60
Silberschatz, Galvin and Gagne 2010 1.61
Silberschatz, Galvin and Gagne 2010 1.62
Silberschatz, Galvin and Gagne 2010 1.63
Silberschatz, Galvin and Gagne 2010 1.64
Silberschatz, Galvin and Gagne 2010 1.65
Silberschatz, Galvin and Gagne 2010 1.66
IDC: Windows Server still rules the server roost
By Mary Jo Foley | June 3, 2010, 7:17am PDT
Q1 2010 units Windows 1,379,487 (75.3%) Unix 65,451 (3.6%) Linux 380,429 (20.8%)
Q4 2009 units
Windows 1,434,225 (73.9%) Unix 84,851 ( 4.4%) Linux 412,041 (21.2%)
Q1 2010 dollars Windows $5.1 billion (48.9%) Unix $2.3 billion (22.2%) Linux $1.7 billion (16.2%)
Q4 2009 dollars
Windows $5.4 billion (41.6%) Unix $3.9 billion (29.9%) Linux $1.9 billion (14.7%)
Silberschatz, Galvin and Gagne 2010 1.67
Desktop OS Market Share
Windows 92.05%
Mac 6.39%
Linux 1.26%
SUN OS 0.00%
Silberschatz, Galvin and Gagne 2010 1.68
Silberschatz, Galvin and Gagne 2010 1.69
Major OS Issues
structure: how is the OS organized?
sharing: how are resources shared across users?
naming: how are resources named (by users or programs)?
security: how is the integrity of the OS and its resources ensured?
protection: how is one user/program protected from another?
performance: how do we make it all go fast?
reliability: what happens if something goes wrong – hardware or software
extensibility: can we add new features?
Silberschatz, Galvin and Gagne 2010 1.70
Major OS Issues
communication: how do programs exchange information
concurrency: how are parallel activities created and controlled?
scale: what happens as demands or resources increase?
persistence: how do you make data last longer than program executions?
distribution: how do multiple computers interact with each other?
accounting: how do we keep track of resource usage, and charge for it?
top related