Problems with Threads
Scheduling
- To execute a threaded program, must rapidly switch between threads.
- This can be done by the user process (user-level threads).
- Can be done by the kernel (kernel-level threads).
Resource Sharing
- Since threads share memory and other resources, must be very careful.
- Operation performed in one thread could cause problems in another.
Synchronization
- Threads often need to coordinate actions.
- Can get "race conditions" (outcome dependent on order of thread execution)
- Often need to use locking primitives (mutual exclusion locks, semaphores, etc...)
|