Introduction
OS
Hardware
Application programs
Users
Kernel
Computer = Device Controller + CPU + Memory + Bus
Bootstrap program
Interrupt/Exception
Memory/Storage
I/O
Single-processor
Multiprocessor
Clustered
OS Structure
Job Scheduling
Virtual Memory
Dual-mode
Process Management
Memory Management
Storage Management
Caching
I/O Subsystem
Operating System Structures
OS Services
User interface
Program execution
I/O operation
File system manipulation
Communication
Error detection
Resource allocation
Accounting
Protection and security
User OS Interface
CLI(CMD)
GUI
System Calls
API (Application Programming Inteface)
Implementation
Parameter Passing
Type of System Calls
Process Control
- Create process / Terminate process
- End, Abort
- Load, Execute
- Get process attributes, Set process attributes
- Wait for time
- Wait, Signal event
- Allocate / Free memory
- Dump memory if error
- Debugger
- Locks
File Management
- Create / Delete file
- Open / Close file
- Read, Write, Reposition
- Get / Set file attributes
Device Management
- Request / Release device
- Read, Write, Reposition
- Get / Set device attributes
- Logically attach / detach devices
Information Maintenance
- Get / Set time or date
- Get / Set system data
- Get / Set process, file, device
Communication
- Create / Delete communication connection
- Send / Receive messages, Passing model
- Shared-memory
- Transfer status
- Attach / Detach remote devices
Protection
- Control access to resources
- Get / Set permissions
- Allow / Deny user access
MS-DOS
FreeBSD
System Programs
File manipulation
File modification
Programming language
Program loading and execution
Communications
Background services
Application programs
OS Desing and Implementation
User Goal
System Goal
Policy
Mechanism
OS Structure
Simple - MS-DOS
More complex - UNIX
Layerd - Abstraction
Microkernel - Mach
OS Debuggin
Log Files
Core Dump
Crash Dump
Profiling
Error / Bug / Exception
System Boot
Firmware
ROM
Bootstrap Loader
Processes
Process Concept
Job
Tasks
Process
Parts
- Text
- Data
- Heap
- Stack
Passive
Active
Process State
New
Running
Waiting
Ready
Terminated
Process Control Block (PCB)
State
Program Counter
Registers
Schduling
Memory Management
I/O Status
CPU Switch Process to Process
Threads
Multiple Program Counter in PCB
Process Scheduling
Multiprogramming
Time sharing
Process Scheduler
Schdeuling Queues
Job Queue
Ready Queue
Device Queue
Schduler
Short-term Scheduler (CPU Scheduler)
Long-term Scheduler (Job Scheduler)
I/O-bound Process
CPU-bound Process
Medium Term Scheduling
Swapping
Context Switch
Operations on Processes
Process Creation
Parent
Child
Process ID (PID)
Process Termination
Exit()
Cascading Termination
Interprocess Communication (IPC)
Independent / Coorperating
Shared Memory
Message Passing
Producer-Consumer Problem
Unbounded / Bounded Buffer
Direct Communication
Send / Receive
Indirect Communication
Port
Send / Receive
Synchronization
Blocking / Nonblocking
Buffering
Communication in Client-Server Systems
Sockets
Port + IP Address
Pipes
Threads
Thread / Process
Single / Multi -threaded Processes
Multicore Programming
Parallelism
Data / Task
Concurrency
Multithreading Models
User / Kernel Threads
Many-to-One
One-to-One
Many-to-Many
Two-Level
Many-to-Many + One-to-One
Implicit Threading
Thread Pools
Faster service
Separating task and ready
Threading Issues
Fork / Exec
Signal Handling
Signals
Signal Handler
Thread Cancellation
Asynchronous / Deferred Cancellation
Thread-Local Storage (TLS)
Process Schdeuling
Concept
Kernel Level Threads
Process / Thread scheduling
CPU Utilization
CUP-I/O Burst Cycle
CPU Sheduler
Short-term Scheduling
Select from Ready Queue
Nonpreemptive / Cooperative
Dispatcher
Switching Context
Dispatch Latency
Scheduling Criteria
Scheduling Algorithm Optimization Criteria
MAX CPU Utilization
MAX Throughput
MIN Turnaround Time
MIN Waiting Time
MIN Response Time
Schdeuling Algorithms
First-Come, First-Serve (FCFS)
Shortest-Job-First (SJF)
Hard to Decide
Exponential Averaging
Shortest-Remaining-Time-First (SRTF)
Priority Scheduling
Smallest Integer = Highest Priority
Starvation
Aging
Round Robin (RR)
Time Quantum
Multilevel Queue
Foreground (Interactive) - RR
Background (Batch) - FCFS
Multilevel Feedback Queue
Move between Queues
Upgrade
Demote
Thread Scheduling
Kernel-level Thread
Process-Contention Scope (PCS)
System-Conetention Scope (SCS)
Multi-Processor Scheduling
Asymmetric Multiprocessing
Symmetric Multiprocessing (SMP)
Processor Affinity
Soft Affinity
Hard Affinity
Load Balancing
Push Migration
Pull Migration
Real-Time CPU Scheduling
Soft Real-Time Systems
Hard Real-Time Systems
Priority-based Scheduling
Periodic
Rate Montonic Scheduling
= SRTF
Earliest Deadline First Scheduling (EDF)
= SJF
Synchronization
Cooperating Process
Race Condition
Critical Section Problem
Entry Section
Critical Section
Exit Section
Remainder Section
Solution
Mutual Exclusion
Progress
Bounded Waiting
Peterson’s Solution
Turn and Flag
Synchronization Hardware
Locking
Atomic
Test Memory
Set Value
Swap Memory
Test and Set
Compare and Swap
Mutex Locks
Acquire / Release
Busy Waiting / Spinlock
Semaphore
Wait / Signal
No Busy Wating
Block / Wakeup
Deadlock and Starvation
Classical Problems of Synchronization
Producer / Consumer
Empty / Mutex / Full
Reader / Writer
rw_mutex / mutex
Dining-Philosophers Problem
Monitors
Automatic Synchronization
Condition Variable
Deadlock
System Model
Request / Use / Release
Deadlock Problem
Wait Each Other
Deadlock Characterization
Mutual Exclusion
Hold and Wait
Nonpreemptive
Circular Wait
Resource-Allocation Graph
Request / Assignment Edge
Deadlock = Cycle
Handling Deadlocks
Preventing
Avoidance
Deadlock Prevention
Sharable Resources
Not Hold and Wait
Preemption
Ordered Wait
Deadlock Avoidance
Avoidance Algorithms
Banker’s Algorithm
Deadlock Detection
Wait-for Graph
Like Banker’s Algorith
Memory Management
Base and Limit Registers
Limit (= Offset)
H/W Address Protection
Address Binding
Binding of Instructions and Data to Memory
Complile Time
Load Time
Execution Time
Logical vs. Physical Address Space
Logical Address (= Virtual Address)
Physical Address
Memory Management Unit (MMU)
Hardware
Relocatio Register (Base Register)