Download ppt

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

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

Document related concepts

Distributed operating system wikipedia, lookup

Spring (operating system) wikipedia, lookup

VS/9 wikipedia, lookup

Process management (computing) wikipedia, lookup

CP/M wikipedia, lookup

Paging wikipedia, lookup

Transcript
Operating Systems
Intro and System Overview
Operating Systems: Internals and Design Principles, 8th ed., Stallings
Modern Operating Systems, 5th ed., Tanenbaum and Bos
Intro
• Intros
• Course Policy
• Syllabus, Textbook
• Learning Objectives
Outline
• OS Evolution
• Modern OS Developments
• System Components
• The Execution Cycle
• Interrupts
• The Memory Hierarchy
• Input and Output
• Multiprocessors
Learning Objectives
• Describe the key functions of an OS
• Discuss the evolution of operating systems, and
explain each major achievement
• Define and discuss virtual machines
• Explain OS design issues raised by multiprocessing
Learning Objectives
• Name and describe the function of common
components in a computer system
• Describe the typical CPU instruction cycle
• Explain the operation of CPU interrupts
• Describe the memory hierarchy, and how its various
elements interact
• Explain the difference between programmed I/O,
interrupt-driven I/O, and DMA
• Understand multiprocessor architecture differences
OS Evolution
Operating System
• A program that controls the execution of application
programs
• An interface between applications and hardware
• Main objectives of an OS
• Convenience
• Efficiency
• Adaptability
(image: XKCD)
Operating System Services
• Program development
• Program execution
• Access to I/O devices
• A computer is a set of resources
for the movement, storage, and
processing of data
• The OS is responsible for
managing these resources.
• Controlled access to files
• System access
• Error detection and response
• Accounting
(image: XKCD)
Evolution of Operating Systems
• Serial processing
• No OS: programmers work directly with hardware
• Users have access to the computer in “series”
• Lots of setup time required
• Simple batch systems
• Multiprogrammed batch systems
• Time-sharing systems
Simple Batch Systems
• Monitor: program that switches jobs
• User no longer has direct access
to the processor
• Monitor is always in memory
• Operator batches jobs together and
places them on an input device
• Each program branches back
to the monitor when finished
• Monitor runs in kernel mode,
user jobs run in user mode
• Example: IBM 701 (~1953)
IBM 701 (image: IBM)
Batch Multiprogramming
• Memory is expanded to hold multiple programs
• Programs, or "jobs," are not interactive with terminal/user
• Controller switches between them without waiting for
program completion
• Example: UNIVAC 1107 / EXEC II (~1962)
UNIVAC 1107 (image: fourmilab.ch)
Time-Sharing Systems
• Can be used to handle multiple interactive jobs
• Processor time is shared among multiple users
• Multiple users simultaneously access system terminals
• OS interleaves the execution of each user program in a
short burst, or quantum, of computation
• Example: CTSS / IBM7094 (mid-late 1960s)
Comparison of Multiprogramming Systems
Batch Multiprogramming
Time Sharing
Principal objective
Maximize processor use
Minimize response time
Source of directives
to operating system
Job control language
commands
Commands entered at the
terminal
No
Yes
Interactive?
IBM 7094
(image: IBM)
Modern OS Developments
Process
• Fundamental to the structure of operating systems
• A process can be defined as:
• A program in execution
• An instance of a running program
• The entity that can be assigned to, and executed on, a
processor
• A unit of activity characterized by at least one sequential
thread of execution, a current state, and an associated set
of system resources
Components of a Process
• A process contains
three components:
– An executable program
– The associated data
needed by the program
– The execution context of
the program
Execution Context
• Internal data the OS uses to
supervise and control a process
• Register contents
• Process priority
• Status: run, suspend, blocked, etc.
Modern OS Developments
• Monolithic Kernel
• Common until ~1990s
• Single process for everything - scheduling, file system,
device drivers, memory management, etc.
• Single shared address space
• Microkernel
• Kernel has only the most
essential functions: scheduling,
address space, IPC, etc.
• All other OS services
implemented separately,
called as needed
Microkernel Advantages
• Flexibility
• Fault tolerance
• Speed
• Simpler implementation
Microkernels
Most OS services
run as modules
that the kernel can
load as needed
The kernel contains
only the most vital OS
components
Simplified structure of the MINIX 3 system
Modern OS Developments
• Multithreading: a process is divided into threads,
which may run concurrently
• Process: a collection of one or more threads, and
associated system resources
• Thread: a dispatchable unit of work, which includes the
process' context
• Symmetric Multiprocessing (SMP)
• OS may take advantage of SMP by scheduling threads
appropriately
Modern OS Developments
• Distributed operating system
• Provides the illusion of:
• A single main memory space
• A single secondary memory space
• Unified file system and other features
• Object oriented design
• Improves OS extensibility, eases development
• Examples: .NET framework, Objective-C/Cocoa
Virtualization
• Enables a single PC or server to simultaneously run
multiple OS's or sessions of an OS
• A machine can host
numerous applications,
including those for a
different OS, on one
platform
• Host OS can support
a number of VMs
Virtualization
• Type I - VMM/Hypervisor runs on hardware
• Examples: VMware ESX, Xen
• Type II - VMM/Hypervisor is 'hosted'
• Examples: VMware Workstation, Parallels, VirtualBox
Apps for
OS #1
Apps for
OS #2
Apps for
OS #3
Guest OS
#1
Guest OS
#2
Guest OS
#3
Apps for
OS #1
Apps for
OS #2
Guest OS
#1
Guest OS
#2
Apps for
Host OS
Type II VMM
Type I VMM - sees hardware state
Host Operating System
Hardware
Hardware
OS Design for Multiprocessing
• Concurrent processes or threads
• Re-entrant kernel routines, etc.
• Scheduling
• Synchronization
• Mutual exclusion and event
ordering
• Memory management
• Reliability
• Graceful degradation if a
processor fails
(image: yogamammaexhales.blogspot.com)
Computer System
Overview
Operating System Functions
• Employs hardware resources of one or more
processors
• Provides a set of services to system users
• Manages secondary memory and I/O devices
Key Interfaces
• Instruction set architecture (ISA)
• Components: registers, flags, timers, interrupts, etc.
• Machine code instruction definitions
• Examples: IA64, x86, MIPS, SPARC
• Application binary interface (ABI)
•
•
•
•
Conventions: e.g. 2's complement, big endian, etc.
How functions are called and arguments are passed
How the OS should manage syscalls
Format of binary executable files
• Application programming interface (API)
• Exported to applications by the OS
Computer System Elements
• Processor (or CPU)
• Controls system operation
• Main Memory
• Volatile, stores data and programs
• Also called "real memory" or "primary memory"
• I/O Modules
• Move data between computer and external environment,
such as hard disk, display, keyboard, etc.
• System Bus
• Facilitates communication among processors, main
memory, and I/O modules
Special-Purpose Processors
• GPUs - graphical processing units
• Efficient computation on arrays
using Single-Instruction
Multiple Data (SIMD)
• Numeric processing, physics
simulations, games, large
spreadsheet computation
• Parallel computing standards:
CUDA, OpenCL
Radeon HD 7970M
(image: diit.cz)
28nm, OpenGL, DirectX, 2.2 TFLOPS, 75W
• DSPs - digital signal processors
• Streaming audio or video ('codecs'),
encryption
(image: ti.fleishman.de)
Special-Purpose Processors
• SoC - system on chip
• Components like DSP, GPU, main memory, cache, and
I/O controllers can all go onto a single chip (or "die")
• May include analog and
mixed-signal components
• Often used in embedded
applications
A8X SoC for iPad Air 2:
Tri-core ARM v8 CPU
Eight-core PowerVR GPU
(image: anandtech.com)
CPU and Execution
CPU Components
• Registers
• General Purpose (x86: $EAX, $EBX, $ECX, $EDX)
• Base Pointer ($EBP in x86)
• Instruction Pointer ($EIP in x86)
• May be called Program Counter
• Stack Pointer ($ESP in x86)
• Program Status Word (PSW)
• Conditions, flags, etc.
• Set by instructions, comparisons, CPU mode, etc.
• Execution Pipeline
Execution Pipeline
Simple
Processor
Superscalar
Execution
Memory
Memory
• Going down the hierarchy:
•
•
•
•
Decreasing cost per bit
Increasing capacity
Increasing access time
Decreasing frequency of access by the processor
Memory Levels
• CPU Registers
• Access in as little as 1 clock cycle
• Cache
• Invisible to the OS
• Exploits the principle of locality
• Internal Memory
• Usually volatile
• Secondary Storage
• Usually external, non-volatile
• Used for programs and files
Cache Principles
• Contains a copy of a portion of main memory
• Processor first checks cache
• If not found, a block of memory is read into the cache
single-level cache
multi-level cache
Memory
(a) A quad-core chip with a shared L2 cache
(b) A quad-core chip with separate L2 caches
Memory Performance
Main Memory
Cache
(RAM vs. Cache)
Virtual Memory
(Paging)
(Disk vs. RAM)
Disk Cache
(Disk swapfile)
(Disk vs. RAM)
5:1
106:1
106:1
Hardware
Hardware and
Software
Software
Typical Block Size
4-128 bytes
64-4096 bytes
64-4096 bytes
Processor Access
Direct
Indirect
Indirect
Typical Access
Time Ratios
Management
System
Locality
• Spatial Locality
• Tendency of execution to involve a number of memory
locations that are clustered
• Temporal Locality
• Tendency for a processor to access memory locations that
have been used recently
Input and Output
Programmed I/O
• The I/O module performs the requested action then
sets the appropriate bits in the I/O status register
• The processor polls the I/O module status
• System performance is severely degraded
Interrupt-Driven I/O
• Processor issues an I/O command to a module,
then goes on to do some other useful work
• I/O module interrupts processor when it has
acquired the data in a buffer
• Processor transfers the data from buffer to memory
• More efficient than Programmed I/O, but still
requires the processor to transfer the data
Direct Memory Access (DMA)
• Performed by a separate module on the system bus
• Transfers the entire block of data directly to and from
memory without going through the processor
• More efficient than interrupt-driven or programmed I/O
• Processor issues a command to the DMA module
containing:
•
•
•
•
Read or write
I/O device address
Starting address in memory
Number of words to be read/written
Buses
Intel x86 System Structure Example
Multiprocessor
Architectures
Multiprocessing
• SMP - Symmetric multiprocessors
• Two or more similar processors of comparable capability
• All processors can perform the same functions
• Interconnected, share
main memory and I/O
• Advantages
• Performance
• Scalability
• Fault tolerance
Multiprocessing
• Multicore
• Two or more processors (cores) on a single die
• Each core has execution unit, registers, local cache
• Core may employ
multiple threads
Core 0
Core 1
Core 2
Core 3
Core 4
Core 5
32 kB 32 kB
L1-I L1-D
32 kB 32 kB
L1-I L1-D
32 kB 32 kB
L1-I L1-D
32 kB 32 kB
L1-I L1-D
32 kB 32 kB
L1-I L1-D
32 kB 32 kB
L1-I L1-D
256 kB
L2 Cache
256 kB
L2 Cache
256 kB
L2 Cache
256 kB
L2 Cache
256 kB
L2 Cache
256 kB
L2 Cache
Intel Core-i7 990X
12 MB
L3 Cache
DDR3 Memory
Controllers
3 8B @ 1.33 GT/s
QuickPath
Interconnect
4
20b @ 6.4 GT/s
Multiprocessing
• Challenges
• Workload balance (scheduling)
• Fault redundancy
• Scalability of intercommunications (bus traffic)
• Coherency of distributed operations
• Cache coherency
• Instruction ordering
Summary
• OS Evolution
• Modern OS Developments
• System Components
• The Execution Cycle
• Interrupts
• The Memory Hierarchy
• Input and Output
• Multiprocessors