Printer-Friendly
Version
|
Next: Locking: Performance Considerations
Up: 10-smp
Previous: Spin locks
Subsections
- Assume
,
all running on same CPU.
- prevents higher-priority process from executing.
- Solution: Avoid preempting processes holding a kernel lock.
- Blocked high-prio process helps locker by donating time
slices.
- Also called wait-free locking[CSL$^+$87].
- Everything needs to be prioritised.
- Need to record holder of lock.
- No good if holds lock too long.
- Ensure all data is always consistent
- Perform changes on shadow copies
- When completed, perform atomic swap
- eg swap pointers with atomic compare-and-swap instruction
- use mp_spinlock if no such instruction
- practically limited to simple data structures (linked lists)
Best to avoid long critical sections in kernel!
-
- Giant lock:
- lock whole kernel.
- Only one process can execute in kernel.
- Similar to dedicated OS processor.
- Coarse-grain locks:
- lock whole subsystems.
- E.g., all TCBs, file system.
- Marginal improvement over giant lock, not scalable.
- Fine-grain locks:
- lock as little as possible at a
time.
- Potential for large amount of parallelism.
- Only suitable approach for large numbers of CPUs.
- Usual deadlock-avoidance schemes apply (numbering locks).
- May not always know in advance which locks are needed.
- Release lock temporarily to obtain lower-numbered one.
- Must leave DS consistent when releasing.
- Must recheck state after reacquiring.
Next: Locking: Performance Considerations
Up: 10-smp
Previous: Spin locks
Gernot Heiser
2002-10-11
|