Upload
herbert-jordan
View
215
Download
0
Embed Size (px)
Citation preview
CSCI/CMPE 4334 Operating Systems CSCI/CMPE 4334 Operating Systems Review: Exam 1Review: Exam 1
1
Review
• Chapters 1 ~ 6 in your textbook
• Lecture slides
• In-class exercises (on the course website)
• Review slides
2
Review
• 5 questions (100 points) + 1 bonus question (20 points)
• Question types– Q/A
3
Time & Place & Event
• 2:35pm ~ 3:50am, Feb. 25, Tuesday
• ENGR 1.290
• Closed-book exam
4
Chapter 1: Introduction and Overview of Operating Systems
• Computer system– Hardware– Software
• Application software• System software
– Operating system
• Operating system– resource abstraction: software & hardware abstraction– resource sharing: time & space multiplexing
• Operating Systems Strategies
5
Chapter 1: Software Classification
6
LoaderLoader
OSOSDatabaseManagement
System
DatabaseManagement
System
WindowSystem
WindowSystem
ApplicationProgrammer
Sys
tem
Sof
twar
e
LibrariesLibraries
CompilerCompiler
Hardware
CommandLine
Interpreter
CommandLine
Interpreter
LibrariesLibrariesLibrariesLibraries
Software APISoftware API
Chapter 1: Purpose of an OS(What is Resource Management?)
• “An OS creates resource abstractions”
• “An OS manages resource sharing”
7
Chapter 1: Operating System Functions
• Resource manager– manage hardware and software resources
– Resource abstraction and sharing
• A nicer environment– implement a virtual machine for processes to run in
• A program in execution is called a process
– a nicer environment than the bare hardware
8
Chapter 1: Abstract Resources
9
Hardware Resources
OS
OS Resources (OS Interface)
Middleware
Abstract Resources (API)
Application
User Interface
Chapter 1: Resource Management Functions
• Transform physical resources to logical resources– Resource abstraction
• Make the hardware resources easier to use
• Multiplex one physical resource to several logical resources– Create multiple, logical copies of resources
• Schedule physical and logical resources– Decide who gets to use the resources
10
Chapter 1: Resource Sharing
• Two types of sharing– Time multiplexed sharing
• time-sharing
• schedule a serially-reusable resource among several users
– Space multiplexed sharing• space-sharing
• divide a multiple-use resource up among several users
11
Chapter 1: Operating Systems Strategies
• Several different strategies have been used– Earliest computers were dedicated to a single
program and there was no multiprogramming and no OS
– Batch systems– Timesharing systems– There are a few other recent strategies
• Personal computers and workstations• Embedded systems• Small, communicating computers• Network technology
12
Chapter 2: Using the Operating System
• Operating systems provide a virtual computing environment for application programmers– Functions provided by O.S.– Abstract resources by O.S.
• Files• Processes and threads• Objects
– Programmers can develop applications more efficiently
13
Chapter 2: Using the Operating System (cont'd)
• Process – an infrastructure in which execution takes place– address space + resources
• Thread– a program in execution within a process context– each thread has its own stack– Components
• program counter• register set • stack space
14
Chapter 2: Using the Operating System (cont'd)
• UNIX fork() creates a process– Creates a new address space– Copies text, data, & stack into new address space– Provides child with access to open files
• UNIX wait() allows a parent to wait for a child to terminate
• UNIX execve() allows a child to run a new program• UNIX sleep() allows a process to suspend itself for
some time• Windows CreateProcess() and CreateThread()• Examples of using functions above (see lecture slides)
15
Chapter 2: Processes vs. Threads
• Benefits of multithreading– Improve application responsiveness
• Netscape uses multithreaded programming
– Use multiprocessors efficiently
– Improve program structure
– Use fewer system resources
– Faster to switch between threads than processes
16
Chapter 2: Algorithms, Programs, and Processes
17
Data
FilesFiles
Files
OtherResources
AlgorithmAlgorithm
Idea
SourceProgram
SourceProgram
BinaryProgram
Execution Engine
Process
StackStatus
Chapter 2: Process Abstraction
18
Hardware
DataData
ProcessProcess
Sta
ck
Processor
ExecutableMemory
ProgramProgram
Operating SystemOperating System
Chapter 2: A Process with Multiple Threads
19
Data
FilesFiles
Files
OtherResources
BinaryProgram
Process
StackStatus
StackStatus
StackStatus
Thread (Execution Engine)
Chapter 2: The File Abstraction
20
Hardware
DataData
ProcessProcess
Sta
ck
Processor
ExecutableMemory
ProgramProgram
Operating SystemOperating System
StorageDevice
FileFile
FileDescriptor
FileDescriptor
Chapter 3: OS Organization
• Basic OS Responsibilities• Basic OS Functions• Three basic implementation mechanisms
– Processor modes• What are Supervisor & user modes? How to switch between them?• What are privileged instructions?
– I/O instructions, and instructions to change the mode or set the halt flag
– Kernels• What is trap instruction for? How to use it?
– Method of invoking system service• How to perform a system call or message passing?
21
Chapter 3: Basic OS Organization
22
Processor(s) Main Memory Devices
Process, Thread &Resource Manager
MemoryManager
DeviceManager
FileManager
Chapter 3: Device Management
• OS uses policies chosen by designer or system administrator to manage– Allocation
– Isolation
– Sharing
• Device manager in two parts– Device independent – provides unified interface
– Device dependent – device driver: handles those aspects unique to a device
23
Chapter 3: Process Management
24
ProtectionProtection
DeadlockDeadlockSynchronizationSynchronization
ProcessDescription
ProcessDescription
ResourceManager
ResourceManagerResource
Manager
ResourceManagerResource
Manager
ResourceManager
Process Mgr
SchedulerScheduler
CPUCPU
Other H/WOther H/W
Chapter 3: Memory Management
25
PrimaryMemory
ProcessManager
ProcessManager
BlockAllocation
BlockAllocation
VirtualMemory
VirtualMemory
Isolation &Sharing
Isolation &Sharing
StorageDevices
Chapter 3: File System Management
26
Chapter 3: Processor Modes• Mode bit: Supervisor or User mode
– Some processors may have more than one mode
• Supervisor mode (privileged, protected)– Can execute all machine instructions
– Can reference all memory locations
• User mode– Can only execute a subset of instructions
– Can only reference a subset of memory locations
27
Chapter 3: Trap Instruction
28
…fork();…
fork() {…trap N_SYS_FORK()…}
sys_fork()
sys_fork() {/* system function */ … return;}
KernelTrap Table
Chapter 3: How to Make a System Call
• For the system– through a trap instruction which causes an interrupt
• Hardware saves PC and current status information
• Hardware changes mode to system mode
• Hardware loads PC from system call interrupt vector location.
• Execute the system call interrupt handler
• return from the handler, restores PC and other saved status information
• User process continues.
29
Chapter 3: Message Passing
30
send(…, A, …);receive(…, B, …);
receive(…A, …); …send(…, B, …);
send/receive
Chapter 4: Device Management
• Abstract all devices (and files) to a few interfaces• Device management strategies
– Direct I/O with polling– Direct I/O with interrupts– DMA I/O with interrupts– How to use the above strategies to perform I/O?
• Buffering & Spooling• Access time of disk device*
– FCFS, SSTF, Scan/Look, Circular Scan/Look– See examples in Exercise (2)
31
Chapter 4: Device Management Organization
32
ApplicationProcess
ApplicationProcess
FileManager
FileManager
Device Controller
CommandCommand StatusStatus DataData
Hardware Interface
System Interface
Device-IndependentDevice-Independent
Device-DependentDevice-Dependent
Chapter 4: Direct-Memory Access
33
Chapter 5: Implementing Processes,Threads, and Resources
• Modern process
• Address space
• Context switching
• State diagram
34
Chapter 5: Classic Processes
• New abstraction divides aspects of classic process into two parts– Modern process: the part that defines a customized
computational framework in which a program executes
– Thread: the part that keeps track of code executions within this framework
• Classic process = modern process with 1 thread
35
Chapter 5: The Address Space
36
ProcessProcess
AddressSpace
AddressBinding
ExecutableMemory
Other objects
Files
Chapter 5: Modern ProcessComposed of:
• Address space
• Program to define behavior of process
• Data used by process
• Resources needed for thread execution– Process created with a minimal set of resources
– Additional resources allocated as needed
37
Chapter 5: Context Switching
38
CPU
New Thread Descriptor
Old ThreadDescriptor
Chapter 5: Simple State Diagram
39
ReadyBlocked
Running
Start
Schedule
Request
Done
Request
Allocate
Chapter 5: A Generic Resource Manager
40
ProcessProcess
Resource Manager
ProcessProcessProcessProcessProcessProcess
Blocked Processes
Resource Pool
request()
release()
Policy
Good Luck!
Q/A
41