Threading Issues (time)
Understand these thread-related issues:
- Event-based UI models as pseudo-threading
- Interrupts vs threading
- Events/interrupts vs polling
- Non-repeatability of behaviour (correct and buggy)
Things to watch:
- Don't overdo threading: overhead will kill you
- Chose appropriate lock granularity
- Make sure you are right in theory and practice!
Notes:
EXAMPLE: Browsers used multiple TCP/IP connections to overcome 3xRTT (approx) setup latency; directory scanning algorithms can run many times faster even within one partition allowing better queueing of disk activity in OS.
Lock granularity: bigger locks and around code rather than data tend to easier to program and less error-prone but may reduce concurrency; finer-grained data-based locks may proved better if so. You usage patterns will determine this.
- What is/are your main reason(s) for threading?
- Can you test results of your tinkering on your target system?
- Do you have multiple targets to optimise for some combination of?
Interrupts can be very expensive, eg for high-speed serial I/O; Sun uses combination of interrupts and polling for serial I/O. Strange effects on serial-connected clocks and NTP timekeeping, eg DHD Arcron code.
Interrupt code may be a special flavour of thread on some systems.