Simple User Thread Library
1.0.0
- Version:
- 1.0
- Date:
- 18/09/2009
- Author:
- Kartik S
This library was written to demonstrate various multithreading models. There are 3 models --
- Many to One (this program)
- One to One (Linux PThreads)
- Many to Many (Solaris Threads)
A simple Many to One user-thread library has been implemented. PThreads and Solaris thread libraries implement the other 2 models. We can also implement the last 2 models, but it becomes complicated because the global threading structures have to be protected by synchronisation (using SIGUSR1, SIGUSR2 or using semaphores). The last 2 models can use the clone() system call.
- A simple Many to One (many user threads are mapped to a single kernel thread) model has been implemented
- Interval timers have been used to transfer control to the thread scheduler periodically
- Scheduling is Round Robin
- Each thread gets a time slice of 1 second (too much)
- Note:
- The threads should not do something fancy like generate signals, since signals have not been taken care of by the thread library
- A fork() duplicates ALL the threads, not just the calling thread
- setitimer() and getitimer() should not be used by the threads
- This library is specific to the Intel 386 processor Specify the option '-march=i386' while compiling with g++
- Bug:
- If the timer goes off while the context is being switched, then GONE CASE.