View
217
Download
3
Embed Size (px)
Citation preview
Winter 2002 1
CMPE 155
Week 2
Winter 2002 2
Review?
Computers Operating Systems Kernels Distributed Systems
Winter 2002 3
Computer
“Hardware”. Processor(s), main memory, disk(s),
keyboard, display(s), network interface, other I/O devices.
Winter 2002 4
Multiple Processor Systems (1)
“Tightly-coupled”– Shared-memory muliprocessor
P ……
Shared Memory
Winter 2002 5
Multiple Processor Systems (2)
“Less tightly-coupled”– Message-passing multicomputer
P ……M
PM
PM
PM
Winter 2002 6
Multiple Processor Systems (3)
“Loosely-coupled”– Distributed systems”
Network
Computer
ComputerComputer
Computer
Winter 2002 7
What is an OS?
Machine/resource manager.
Physical Devices
MicroarchitectureInstruction Set Architecture
Operating System
Compilers, Editors, etc.
Hardware
Application programs
Winter 2002 8
OS as extended machine…
Top-down view. Layer of software that hides hardware. Provides programmer easier instructions.
– E.g., read block from file.
(Part of) the OS runs in supervisor (privileged) mode: can execute priviledged instructions (e.g., access to physical decices through drivers).
Winter 2002 9
OS as resource manager
Bottom-up view. Provides orderly and controlled
allocation of resources. Provides (“concurrent”) programs (fair)
access to resources (processor, disk, printer).
Time (e.g., CPU) and space (e.g., memory) multiplexing.
Winter 2002 10
OS History
Winter 2002 11
First generation: 1945-1955 Vacuum tubes: machines took whole
rooms! Machine language programming
(plugboard wiring). No OS.
Winter 2002 12
Second generation: 1955-1965 Transistors made computers
commercially viable. Builders, operators, users. Mainframes: multimillion dollar
machines. Punch cards, input and output tapes. Batch systems.
Winter 2002 13
Third generation: 1965-1980 ICs. Multiprogramming.
– Machine shared by “concurrent” programs.– Memory partitions hold multiple jobs.
Timesharing.– Multiprogramming still batch processing: scientific
computation and commercial data processing.– Cheap terminals: interactive use.– Interactive service + batch processing.
Winter 2002 14
Fourth generation: 1980-… High-scale circuit integration. Computer miniaturization. Mainframes -> minicomputers ->
microcomputers or PCs. PC OSs: CP/M, DOS, MS-DOS. GUI-based OSs: UNIX-based, MS
Windows-based, MAC OS, …
Winter 2002 15
Modern OSs Mainframe OSs: IBM’s OS/390, DEC’s
VMS. Server OSs: Solaris, FreeBSD, etc. PC OS: Linux, MacOS, Windows… Real-time OSs: VxWorks. Embedded OSs: Linux, PalmOS,
Windows CE Smart card OSs
Winter 2002 16
Basic OS Concepts
Winter 2002 17
Processes
Process: program in execution.– Address space: memory usable by
program (text, data, stack).– State: registers.
OS uses process table to keep track of processes.
Processes can create other (child) processes.
Winter 2002 18
Inter-Process Communication (IPC) Shared memory.
– Processes communicate/synchronize through a shared data item.
Message passing.– Processes communicate via messages.
Winter 2002 19
Shared Memory
Processes must access shared data in a mutual exclusive way.
Primitives:– Semaphores: Dijkstra(1965)
• P(S) and V(S) operations.• Atomic (indivisible) operations.
– (Conditional) Critical Regions– Monitors
Winter 2002 20
Message Passing
Processes communicate/synchronize by sending/receiving messages.
Primitives:– Send(message), receive(message).
Issues:– Synchronous versus asynchronous.– Reliable versus unreliable.
Winter 2002 21
Distributed Shared Memory
Sharing data among computers that don’t share physical memory.
DSM provides shared memory abstraction.– Read- and write-like primitives.
Needs message passing to convey updates among physically disjoint processing elements.
Winter 2002 22
Deadlocks
Shared data/resource may lead to deadlock: processes get “stuck”.
Example: v is using r1 and requests r2; w is using r2 and requests r1.
v w
Winter 2002 23
Memory Management
Share memory among several processes. Monoprogramming: memory sharing between
OS and program (embedded OSs). Multiprogramming: multiple processes
(partially or totally) in memory.– Swapping.– Virtual memory: paging.
Winter 2002 24
I/O
OS I/O subsystem manages I/O devices.– Device-dependent (device drivers) or independent.
File system:– File as an abstraction.– Basic operations: create, delete, read, write.
Hierarchical file systems.– Dynamically attach tree branches (e.g., mount
system call in UNIX). Access control: permissions.
Winter 2002 25
System Calls Interface between OS and user program: set of
system calls.– E.g., access a file, create a process, etc.
Like making a special procedure call.– System calls executed by kernel.– Calling program pushes parameters onto stack; calls
library; library routine (same name as system call) executes TRAP, switching to kernel mode; OS handles call; returns control to library; library returns to user program.
Example system calls for file system– open, close, read, write, mkdir, rmdir.
Winter 2002 26
System Calls
User-level process
Kernel
Physical machine
System callto access physical resources
System call: implemented by hardware interrupt (trap) which puts processor in supervisor mode and kernel addressspace; executes kernel-supplied handler routine (device driver)executing with interrupts disabled.
Winter 2002 27
Kernels
Executes in supervisor mode.– Privilege to access machine’s physical
resources. User-level process: executes in “user”
mode.– Restricted access to resources.– Address space boundary restrictions.
Winter 2002 28
Kernel Functions Memory management.
– Address space allocation.– Memory protection.
Process management.– Process creation, deletion.– Scheduling.
Resource management.– Device drivers/handlers.
Winter 2002 29
Kernel and Distributed Systems
Inter-process communication: RPC, MP, DSM.
Distributed (Networked) File systems. Some parts may run as user-level and
some as kernel processes.
Winter 2002 30
Be or not to be in the kernel?
Monolithic kernels versus microkernels.
Winter 2002 31
Monolithic kernels
• Examples: Unix, Sprite.
• “Kernel does it all” approach.
• Based on argument that inside kernel, processes execute more efficiently and securely.
• Problems: massive, non-modular, hard to maintain and extend.
Winter 2002 32
Microkernels Take as much out of the kernel as possible. Minimalist approach. Modular and small.
– 10KBytes -> several hundred Kbytes.– Easier to port, maintain and extend.– No fixed definition of what should be in the kernel.– Typically process management, memory
management, IPC. Example: Mach (CMU),
Winter 2002 33
Micro- versus Monolithic Kernels
S1 S4 S3
S4
S1 S4S2 S3
Monolithic kernel Microkernel
Services (file, network).
Kernel code and data
Winter 2002 34
Microkernel
Application
OS Services
Microkernel
Hardware
. Services dynamicallyloaded at appropriateservers.
. Some microkernelsrun service processes only @ user space; others allow them to beloaded into eitherkernel or user space.
Winter 2002 35
Extensible Kernels “Extensible” OS. Provides core set of extensible services +
extension infrastructure. Extensions: allow applications to specialize
the underlying OS to achieve performance and functionality.– Extensions can be loaded into kernel any time.
Example: general purpose OS doesn’t provide adequate disk management for database applications.
Winter 2002 36
Extensions Applications can extend OS servers to
provide better match for its needs. Goal: build general purpose OS that
provides extensibility+safety+performance.
Example: UofWashington’s SPIN kernel.