1/83
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Monitor
A lock + condition variables
Lock
provides mutual exclusion to shared data.
a lock provides two operations
-Acquire()
-Release()
Condition Variable
provides a queue for waiting threads inside a critical section
each conditional variable
-consists of a queue of threads
-Provides three operations
**wait()
**Signal()
**Broadcast()
Hoare vs. Mesa Monitors
Hoare Monitors (used in most textbooks)
-Signal() transfers the CPU directly to a waiting thread.
Mesa Monitors (used in most real operating systems)
-Signal() only puts a waiting thread on the scheduler's ready queue
-By the time the waken thread gets the CPU, the waiting condition may no longer be true and needs to be retested.
Semaphores VS Monitors
We can't quite implement monitors with semaphores.
Condition variables only work inside a lock
-using semaphores inside a lock may deadlock
Condition variables have no history, but semaphores have
-Signal() with an empty queue does nothing
**A subsequent Wait() will wait
-V() increments semaphore
**A subsequent P() will not wait
-Wait() will always wait
-P() might not wait
Deadlock
Occur when threads are waiting for resources with circular dependencies.
Deadlock implies starvation
Preemptable Resource
EX- CPU
can be resolved by reallocation of resources
Nonpreemptable Resource
A resource that cannot be taken away from its current owner without causing computation to fail
Starvation
a thread waits indefinitely
Checkpointing
taking snapshots of system states from time to time
Four Conditions for Deadlocks
limited access (lock-protected resources)
no preemption (if someone has the resource, it cannot be taken away)
wait while holding (holding a resource while requesting and waiting for the next resource)
circular chain of requests
Banker's Algorithm
-A thread states its maximum resource needs in advance.
-The OS allocates resource dynamically as needed. A thread waits if granting its request would lead to deadlocks.
-A request can be granted if some sequential ordering of threads is deadlock free.
Deadlock Recovery Techniques
Scan the resource allocation graph
Detect circular chains of requests
Recover from the deadlock
Interprocess Communication
Processes communicate among address spaces.
-Bug stream ex. pipe
-Message passing (send/receive)
-File system (read and write)
-Shared memory
Direct
-send(P1, message)
System Call
A user process asks the OS to do something on the process's behalf.
Hardware-Supported Mechanisms
Address translation
Dual-mode operation
Software-Supported Mechanisms
Strong Typing
Software Fault Isolation
Steps to switch between kernel and user spaces
-Creates a process and initialize the address space
-Loads the program into the memory
-Initializes translation tables
-Sets the HW pointer to the translation table
-Sets the CPU to user mode
-Jumps to the entry point of the program
Context switching between processes vs. threads
Unlike context switching among threads, to switch among processes
-Need to save and restore pointers to translation tables
To resume process execution
-Kernel reloads old register values
-Sets CPU to user mode
-Jumps to the old program counter
Segment
A logically contiguous memory region
External Fragmentation
memory wasted because the available memory is not contiguous for allocation
Internal Fragmentation
allocated pages are not fully used
Translation Lookaside Buffers
Store recently translated memory addresses for short-term reuses
base and bound translation
Segmentation-based Translation
use a table of base-and-bound pairs
Paging-based translation
memory allocation via fixed-size chunks of memory, or pages
Segmented-paging translation
breaks the page table into segments
paged page tables
two-level tree of page tables
Caching
Storing copies of data at places that can be accessed more quickly.
temporal locality
Recently referenced locations are more likely to be referenced soon.
spatial locality
Referenced locations tend to be clustered.
Cache pollution
Leaving behind cache content with no localities.
Translation Lookaside Buffer (TLB)
virtually addressed cache
between the CPU and the translation tables
Physical addressed cache
between the translation tables and the main memory
Design issues of caching
Four types of cache misses
Ways to perform TLB lookups
write-through caching policy
Immediately propagates update through various level of caching.
write-back caching policy
Delays the propagation until the cached item is replaced.
Demand Paging
Allowing pages that are referenced actively to be loaded into memory.
page fault
A referenced page is not in memory.
Transparent
(invisible) mechanisms
Belady's Anomaly
Adding more frames can cause more page faults.
Thrashing
When the memory is overcommitted.
Working Set
Pages that are referenced within the past T seconds.
Steps to carry out a page fault
Page replacement policies
Polling
A CPU repeatedly checks the status of a device.
Interrupt-driven I/Os
A device controller notifies the corresponding device driver when the device is available.
Direct Memory Address
Using an additional controller to perform data movements.
Device Controller
Converting between serial bit stream and a block of bytes.
Device Driver
An OS component that hides the complexity of an I/O device.
Memory-mapped I/O
Making no distinction between device addresses and memory addresses.
Categories of I/O Devices
block device
character device
network device
ways to access a device
Polling
interrupt-driven I/O's
Direct Memory Access (DMA)
Double Buffering
disk arm scheduling policies
Disk Platters
coated with magnetic materials for recording
Disk Arm
moves a comb of disk heads
Sector
the smallest unit of disk storage
Cylinder
consists of all tracks with a given disk arm position
Zone Bit Recording
zones near the edge store more information (higher bandwidth)
Track
each disk platter is divided into concentric tracks
Track skew
starting position of each track is slightly skewed
Thermo-calibrations
performed to account for changes of radius due to temperature changes
Seek time
the time to position disk heads (~4 msec on average)
Rotational Latency
the time to rotate the target sector to underneath the head
Transfer Time
the time to transfer bytes
Disk access time
seek time + rotational delay + transfer time
Latency
Seek time + rotational delay
Bandwidth
Bytes transferred / disk access time
Block Device
stores information in fixed-size blocks, each one with its own address
(e.g. disks)
Character Device
delivers or accepts a stream of characters, and individual characters are not addressable
(e.g. keyboards, printers)
Network Device
transmits data packets
Flash Memory
form of solid-state memory similar to ROM
NOR Flash
used in cellular phones and PDAs
byte addressable
mostly replaced by DRAM + NAND Flash
Flash Translation Layer (FTL)
Write new version elsewhere
Erase the old version later
flash page
The atomic unit in which data is read from flash memory.
1 flash page ~= 1 disk block
flash blocks
consists of 4-64 flash pages
may not be atomic
double buffering
uses two buffers. While one is being used, the other is being filled