Chapter 1: Introduction
Download
Report
Transcript Chapter 1: Introduction
Chapter 1: Introduction
Chapter 1: Introduction
•
•
•
•
What Operating Systems Do
Computer-System Organization
Operating-System Structure
Operating-System Operations
–
–
–
–
Process Management
Memory Management
Storage Management
Protection and Security
• Distributed Systems
• Real-Time/Embedded Systems
Objectives
• To provide an overview of the major
operating systems components
• To review basic computer system
organization
What is an Operating System?
• A program that acts as an
intermediary between a user
and hardware
• Operating system goals:
– Execute user programs and make
solving user problems easier
– Make the computer system
convenient to use
– Use the computer hardware
efficiently
Computer System Structure
• Computer system can be divided
into four components
– Hardware – provides basic computing
resources
• CPU, memory, I/O devices
– Operating system
• Controls and coordinates use of
hardware among various applications
and users
– Application programs
• Word processors, compilers, web
browsers, database systems, video games
– Users/clients
• People, machines, other computers
Four Components of a Computer
System
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
• Kernel: Core of OS
Computer Startup
• bootstrap program is loaded at powerup or reboot
– Firmware stored in ROM or EPROM
– Initializates the system
– Loads operating system kernel and starts
execution
Computer System
Organization
• CPU(s) & device controllers connect
through common bus providing
access to main memory
Storage-Device Hierarchy
Faster
More Expensive
Caching
• Data temporally copied from slower
to faster storage
• Check cache first
• Cache < Storage being cached
– How to determine appropriate cache
size
– Replacement policy
– Cache coherency in multiprocessor
environment
SRAM
• Stores a bit in a flip-flop
– Two cross connected NAND or NOR gates
– Stores a bit as long as power is applied
– Consumes less power than DRAM but more
complex circuitry
• Generally requires 6 transistors
– More expensive
DRAM
• One transistor + Capacitor
• Electrical charge on capacitor leaks
over time
• Periodically refresh
– Slower than SRAM
– Consumes more power
• Cheaper than SRAM
– Simpler circuitry
Operating System Structure
• Multiprogramming
– Efficient resource usage
– Single user cannot keep CPU and I/O
devices busy at all times
– Organizes jobs so that CPU always has
one to execute
– A subset of total jobs in system is
kept in memory
– When a job blocks, e.g., for I/O, OS
switches to another job
• Timesharing/Multitasking
– CPU switches jobs very frequently
– 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
Memory Layout for
Multiprogrammed System
Operating System Operations
• Hardware Interrupts
• Software error or request creates
exception or trap
– Division by zero
• Other problems: infinite loop,
processes modifying each other or
OS
– Accounting & resource management
– Protection
Basic Protection
• Dual-mode operation
– User mode & kernel mode
– Mode bit
• Distinguish whether system is running
user code or kernel code
• Privileged instructions only executable in
kernel mode
– System call
•
•
•
•
Change to kernel mode
Process the system call
Return the result
Switch back to user mode
Process Management
• A process is a program in execution
– Unit of work
– Single- or multi-threaded
• Resource allocation
– Process needs resources to accomplish
its task
– CPU, memory, I/O, files, data
• Resources reclamation at process termination
• Program counter indicates the location
• Multiple processes can run concurrently on one
or more CPUs
– Concurrency by multiplexing the CPUs
among the processes / threads
Process Management
Activities
• Create and delete both user and system
processes
• Suspend and resume processes
• Provide mechanisms for process
synchronization
• Provide mechanisms for process
communication
• Provide mechanisms for deadlock
handling
Memory Management
• Instruction and data need to be in
main memory to be processed
• Keep track of which parts of
memory are currently used and by
whom
• Decide which processes and data
to move into and out of memory
• Allocate and deallocate memory
space as needed
Mass Storage Management
• Performance bottleneck
– Orders of magnitude performance difference
between main memory & secondary storage
• 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-manytimes) and RW (read-write)
I/O Subsystem
• Hide peculiarities of hardware devices from the user
• I/O subsystem responsible for
– Buffering: store data temporarily while it is being
transferred
– Caching: store parts of data in faster storage
– Spooling (Simultaneous Peripheral Operations OnLine)
• Put data in a designated buffer
• I/O device can pull the data at its own
rate
• Print spooling can let a user do something
else while printing and request several
prints without waiting for one print
request to finish
– Device-driver interfaces
Two I/O Methods
Synchronous
Asynchronous
• Synchronous I/O
• Application is blocked until the I/O finishes
• Only one I/O device is active
• Easy to determine which device needs service
• No concurrent I/O possible
I/O Interrupts
• Extract interrupt service vector
• Look up interrupt service table
• Save the current process status
such as the register values and
address of the interrupted
instruction
• Disable interrupt if necessary
• Transfer control to the interrupt
service routine
Interrupt Timeline
Direct Memory Access
Structure
• Used for high-speed I/O devices able to
transmit information at close to memory
speed
• 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 one interrupt per
byte
• Cycle stealing
Device-Status Table
Computer system architecture
• Single processor systems
• Multiprocessor systems
– Multiple CPUs sharing main memory
– Objectives
• Increase throughput
• Fault tolerance
– Asymmetric multiprocessing
• A master processor controls the system
– Symmetric multiprocessing (SMP)
• All processors are peers
• No master-slave relation
• Multiprocessor systems (continued)
– Multicore CPU
• Essentially multiprocessors on a single chip
• Faster communications between processors
• Uses much less power than multiple single-core
chips
• Good for servers such as web/database servers
• Clustered systems
– A cluster consists of two or more individual
systems unlike multiprocessor systems
– Clustered computers share storage and
linked by a local area network, e.g.,
Ethernet or InfiniBand
– To support fault tolerance and high
performance, for example, in a web server
farm
• Distributed systems
Tips: vmware player
• Available at
http://www.vmware.com/products/pla
yer/
• More info. in page 39
• You don’t have to use it to do
assignments. Try this only if you are
looking for some extra fun and
challenges on your own.