Chapter 1: Introduction

advertisement
Introduction
Source: Operating System Concepts by Silberschatz, Galvin and Gagne
CSC 4103: Operating Systems
1.4
B. B. Karki, LSU
Operating System and Its Versatility
 What is an Operating System (OS)?
 User view, System view
 General-Purpose Systems
 Mainframe systems (Batched, Multiprogramming, Time-sharing OS
structures)
 Single-processor, Multiprocessor, Clustered and Distributed systems
 Special-Purpose Systems
 Real-time, Multimedia and Handheld systems
 Computing Environments
 Traditional, Distributed, Web-based and Embedded computing
 OS development
 Resource-driven history: Hardware changes drive OS change
 Feature migration
CSC 4103: Operating Systems
1.5
B. B. Karki, LSU
What is an Operating System?
 A program that acts as an intermediary between a user
and the computer hardware.
 Manages the computer hardware
 Operating system goals:
 Convenience for the user
 Efficient operation of the computer system
 An OS is similar to a government.
CSC 4103: Operating Systems
1.6
B. B. Karki, LSU
Abstract View of Computer System Components
CSC 4103: Operating Systems
1.7
B. B. Karki, LSU
Two Views on OS
 User View
 Ease of use - resource utilization is of no concern for a PC.
 Maximum resource utilization - a terminal connected to a
mainframe computer or a supercomputer.
 Both individual usability and resource utilization - workstations
and servers.
 Limited or no individual usability - handheld and embedded
computers.
 System View
 Resource allocator – manages and allocates resources.
 Control program – controls the execution of user programs and
operations of I/O devices .
 Kernel – the one program running at all times
 Too much functionality in Microsoft OS.
CSC 4103: Operating Systems
1.8
B. B. Karki, LSU
Mainframe Systems: OS Structures
 Used to tackle scientific and commercial applications
Batched, Multiprogrammed, Time-shared systems.
ENIAC (1945), IBM 7094 (1965), Circa (1976), Supermike (2004)
CSC 4103: Operating Systems
1.9
B. B. Karki, LSU
Batched Systems
 Reduce setup time by batching similar
jobs
 Automatic job sequencing
 When job completes control transfers
back to monitor.
CSC 4103: Operating Systems
1.10
B. B. Karki, LSU
Multiprogrammed Systems
 Several jobs are kept in main memory at
the same time, and the CPU always has
one job to execute
 Memory management
 Job and CPU scheduling
 Allocation of I/O devices.
CSC 4103: Operating Systems
1.11
B. B. Karki, LSU
Time-Sharing Systems
 Interactive computing
 CPU executes multiple jobs from different users as time
evolves.
 CPU scheduling
 A job swapped in and out of memory to the disk.
 On-line communication between the user and the system
is provided.
 Guarantee some acceptable response time to each user.
CSC 4103: Operating Systems
1.12
B. B. Karki, LSU
Single-Processor Systems: Desktops
 Most systems use a single CPU
 Personal computer– computer system dedicated to a single user.
 I/O devices – keyboards, mice, display screens, printers, networks
 Device-specific processors or controllers
 User convenience and responsiveness
 No priority on resource utilization.
 May run several different types of operating systems (Windows,
MacOS, UNIX, Linux)
CSC 4103: Operating Systems
1.13
B. B. Karki, LSU
Multiprocessor Systems
 Also known as parallel systems or tightly coupled systems
 More than one CPU or processor in close communication
 Share the clock, memory, computer bus, and peripheral
devices
 Multicore chips
 Advantages of parallel system:
 Increased throughput
 Economy of scale
 Increased reliability.
CSC 4103: Operating Systems
1.14
B. B. Karki, LSU
Multiprocessor Systems (Cont.)
 Symmetric multiprocessing (SMP)
 Each processor runs an identical copy of the operating system
 Asymmetric multiprocessing
 Each processor is assigned a specific task; master processor schedules
and allocates work to slave processors.
CSC 4103: Operating Systems
1.15
B. B. Karki, LSU
Clustered Systems
 Clustering allows two or more individual systems to share storage
 Systems are coupled together via LAN networking
 Provides high-availability by adding a level of redundancy
 Each node can monitor one or more of others to provide a recovery
mechanism if the monitored machine fails
 Asymmetric clustering: one server or machine runs the
application while other server is in hot-standby mode
 Symmetric clustering: all hosts are running the applications and
are monitoring each other.
CSC 4103: Operating Systems
1.16
B. B. Karki, LSU
Distributed Systems
 Distribute the computation among several physically distributed
processors
 Grid computing
 Loosely coupled system – each processor has its own local memory;
processors communicate with one another through various
communications lines.
 Requires networking infrastructure.
 TCP/IP is the most common network protocol
 OS requires an interface device – a network adaptor
 Local area networks (LAN) or Wide area networks (WAN)
 Notion of network operating system (file sharing, communication)
 Advantages of distributed systems.
 Resources sharing
 Computation speed up – load sharing
CSC 4103: Operating Systems
1.17
B. B. Karki, LSU
Real-Time Systems
 Often used as a control device in a dedicated application:
 Embedded systems
 Well-defined fixed-time constraints.
 Differ from time-sharing or batch systems which have flexibility
with time.
 Variation in real-time systems:
 Hard real-time: guarantees that critical tasks be completed on time.
 Soft real-time: critical task gets priority over other tasks, and retains
that priority until it completes.
CSC 4103: Operating Systems
1.18
B. B. Karki, LSU
Multimedia Systems
 Incorporation of multimedia data into computer systems
 Audio, video and conventional files.
 Increasing number of applications:
 MP3 audio, DVD movies, Video conferencing, Video clips, Live
webcasts, Live webcams
 Desktops and smaller devices.
 Live or real-time streaming:
 Compress multimedia data and maintain frame rate.
CSC 4103: Operating Systems
1.19
B. B. Karki, LSU
Handheld Systems
 Examples:
 Personal Digital Assistants (PDAs)
 Cellular telephones.
 Issues:
 Limited memory
 Slow processors
 Small I/O devices
 Network connectivity:
 Wireless access to e-mail and web browsing.
CSC 4103: Operating Systems
1.20
B. B. Karki, LSU
Computing Environments
How operating systems are used in a variety of computing
environment settings:
 Traditional Computing
 Office and home environment
 Distributed Computing
 Client-server
 Peer-to-peer
 Web-Based Computing
 Wide-spread use
 Emphasis on networking
 Embedded Computing
 Most prevalent
 Continues to expand.
CSC 4103: Operating Systems
1.21
B. B. Karki, LSU
Migration of OS Concepts and Features
MULTICS: Multiplexed information and computing services
CSC 4103: Operating Systems
1.22
B. B. Karki, LSU
Summary 1
 Development of OS over more than 50 years for convenience and
efficiency.
 Mainframe systems - Batched systems, Multiprogramming, Time-
sharing
 PCs – much smaller and less expensive than mainframe systems.
 Parallel, clustered and distributed systems – several CPUs or more
complete computer systems in communication.
 Real-time systems – fixed time constraints, deadline scheduling of
processes.
 A variety of computing environments exist.
CSC 4103: Operating Systems
1.23
B. B. Karki, LSU
Computer-System Structures
Source: Operating System Concepts by Silberschatz, Galvin and Gagne
CSC 4103: Operating Systems
1.24
B. B. Karki, LSU
Computer-System Structures
 Computer System Operation
 System startup
 Interrupt-driven
 Related Hardware Components and Mechanisms
 I/O structure
 Storage structure and hierarchy
 Hardware protection
 Network structure
CSC 4103: Operating Systems
1.25
B. B. Karki, LSU
Computer-System Organization
 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
CSC 4103: Operating Systems
1.26
B. B. Karki, LSU
Computer Startup
 Initial or 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.
 If there are no processes to execute, no I/O devices to service, and no users
to whom to respond, an OS will sit quitely waiting for something to happen.
CSC 4103: Operating Systems
1.27
B. B. Karki, LSU
Interrupts
 An operating system is interrupt driven
 OS executes the first process (such as init) and waits for some
event to occur.
 Occurrence of an event is signalled by an interrupt from either
hardware or software (e.g., trap).
 Interrupt transfers control to the interrupt service routine through
the interrupt vector
 Interrupt architecture must save the address of the interrupted
instruction.
CSC 4103: Operating Systems
1.28
B. B. Karki, LSU
Interrupt and I/O Operation
 CPU and I/O devices can execute concurrently.
 Each device controller is in charge of a particular device type.
 Controller has a local buffer and a set of special-purpose registers.
 CPU moves data from/to main memory to/from local buffers
 I/O is from the device to local buffer of controller or vice versa.
 Device controller informs CPU that it has finished its operation by
causing an interrupt.
CSC 4103: Operating Systems
1.29
B. B. Karki, LSU
Interrupt Time Line For a Single Process Doing Output
 When the CPU is interrupted, it stops what it is doing and immediately
transfers execution to the fixed location of the service routine.
CSC 4103: Operating Systems
1.30
B. B. Karki, LSU
I/O Structure
 Device controller informs CPU (through device driver) that it has finished its
operation by causing an interrupt.
 Synchronous I/O: Control returns to user program (or other OS code) only
upon I/O completion.
 Wait instruction idles the CPU until the next interrupt.
 Asynchronous I/O: Control returns to user program without waiting for I/O
completion.
CSC 4103: Operating Systems
1.31
B. B. Karki, LSU
Device-Status Table
Device-status table - contains entry for each I/O device indicating its
type, address, and state.
CSC 4103: Operating Systems
1.32
B. B. Karki, LSU
Direct Memory Access (DMA) Structure
 Used for high-speed I/O devices for data transfer 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 one
interrupt per byte.
CSC 4103: Operating Systems
1.33
B. B. Karki, LSU
Storage Structure
 Main memory – only large storage media that the CPU can access
directly.
 Programs must be in the main memory to be executed
 RAM or DRAM
 Volatile storage.
 Secondary storage – extension of
main memory that provides large
nonvolatile storage capacity.
 Magnetic disks – rigid metal or
glass platters covered with
magnetic recording material.
CSC 4103: Operating Systems
1.34
B. B. Karki, LSU
Storage-Device Hierarchy
 Design of a
complete
memory
system must
balance all
three factors
 speed,
 Cost
 Size
 Volatility.
CSC 4103: Operating Systems
1.35
B. B. Karki, LSU
Caching
 Use of high-speed memory to hold recently-accessed data
 Copying information into faster storage system – the cache – on a
temporary basis.
 Information in use copied from slower to faster storage temporarily
 Main memory can also be viewed as a fast cache for secondary storage.
 Internal registers provide a high-speed cache for main memory.
 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 is an important design problem
 Cache size and replacement policy
 Can result in 80 to 99% of all accesses being in the cache, greatly
increasing performance.
CSC 4103: Operating Systems
1.36
B. B. Karki, LSU
Performance of Various Levels of Storage
 Movement between levels of storage hierarchy can be explicit or implicit.
CSC 4103: Operating Systems
1.37
B. B. Karki, LSU
Migration of A From Disk to Register
 Caching introduces another level in storage hierarchy.
 Cache consistency:
Data is simultaneously stored in more than one level to be consistent.
The copy of A appears in several places: on the magnetic disk, in main
memory, in the cache and in an internal registers.
 Cache coherency:
Update of a copy of A need to be in all caches where A resides (in a
multiprocessor system with all CPUs having a local cache).
Distributed environment situation is even more complex.
CSC 4103: Operating Systems
1.38
B. B. Karki, LSU
Hardware Protection
 Errors can come from any malfunctioning program.
 Protection of the OS against errors using hardware support:
 Hardware can detect the errors and it will trap to the OS thereby
transferring control to the OS by interrupt.
 Dual-Mode Operation
 I/O Protection
 Memory Protection
 CPU Protection
CSC 4103: Operating Systems
1.39
B. B. Karki, LSU
Dual-Mode Operation
 Provide hardware support to differentiate between at least two modes of
operations:
 User mode – execution done on behalf of a user.
 Kernel mode (also monitor or supervisor or system or privileged mode)
 Execution done on behalf of OS. The computer is under the control of OS.
 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 monitor mode.
 Privileged instructions can be issued or executed only in monitor mode.
They are those machine instructions that may cause harm.
interrupt/fault
kernel
(0)
user
(1)
set user mode
CSC 4103: Operating Systems
1.40
B. B. Karki, LSU
Transition from User to Kernel Mode
 When a user application requests a service from the operating
system (via a system call), it must transition from user mode to
kernel mode to fulfill the request.
CSC 4103: Operating Systems
1.41
B. B. Karki, LSU
I/O Protection
 A user program may disrupt
the normal operation of the
system by issuing illegal I/O
operations
 Writing in an interrupt
vector.
 OS must ensure that a user
program could never gain
control of the computer in
kernel mode.
 All I/O instructions are
defined to be privileged
instructions.
 Use a system call to
perform I/O.
CSC 4103: Operating Systems
1.42
B. B. Karki, LSU
Memory Protection
 Memory protection at least for
the interrupt vector and the
interrupt service routines.
 Two registers-scheme:
Determines the range of legal
addresses a program may
access:
 Base register – holds the
smallest legal physical
memory address.
 Limit register – contains the
size of the range.
 Memory outside the defined
range is protected.
CSC 4103: Operating Systems
1.43
B. B. Karki, LSU
Hardware Address Protection
 The CPU hardware compares every address generated in the user mode
with the registers and allows access to the specified range.
 Any attempt by a user program to access kernel memory or other users’
memory results in a trap to the kernel mode and hence in a fatal error.
CSC 4103: Operating Systems
1.44
B. B. Karki, LSU
CPU Protection
 Prevent a user program from getting stuck in an infinite loop or not
calling system services.
 Timer – interrupts the computer after specified period
 Timer is fixed or variable.
 Timer is also used to implement time sharing.
 Timer is also used to compute the current time.
CSC 4103: Operating Systems
1.45
B. B. Karki, LSU
Network Structure
 Two types of networks based on how they are geographically
distributed:
 Local Area Networks (LAN)
 Processors distributed over small geographical areas (such as single
building or a number of adjacent buildings).
 Wide Area Networks (WAN)
 Processors distributed over a large geographical area (such as the US).
 Variations in speed and reliability communications
 LAN has a higher speed, lower error rate and more expensive connections
CSC 4103: Operating Systems
1.46
B. B. Karki, LSU
Local Area Network Structure
CSC 4103: Operating Systems
1.47
B. B. Karki, LSU
Wide Area Network Structure
CSC 4103: Operating Systems
1.48
B. B. Karki, LSU
Summary 2








Multiprogramming and time-sharing systems improve performance by overlapping CPU
and I/O operations. Such an overlap requires that transfer between CPU and I/O device
be handled by interrupt-driven access to an I/O port, or by a DMA data transfer.
Programs that need be executed by a computer must be in main memory which is directly
accessible to CPU but it is volatile. Secondary storages (e.g., magnetic disk) are needed
to hold program and data permanently.
Different storages (registers, cache, main memory, electronic disk, magnetic disk, optical
disk and magnetic tapes) can be organized in a hierarchy according to their speed and
cost. Moving down the hierarchy, the cost per bit decreases whereas the access time
increases.
Hardware has two modes: user mode and kernel mode. Various instructions including I/O
are privileged, and can be executed in only kernel mode thus avoiding users’ illegal
execution of those instructions.
The memory in which OS resides must be protected from the modification by a user
program by allowing an access to only the addresses defined by the base and limit
registers.
A timer prevents infinite loops thereby protecting CPU.
Facilities such as dual mode, privileged instructions, memory protection and timer
interrupt are basic building blocks used by OS to maintain control and achieve correct
operation.
LANs and WANs are the two basic types of networks differing in their geographical
extension, communication speed and reliability.
CSC 4103: Operating Systems
1.49
B. B. Karki, LSU
Download