Title: Advanced Linux Threads Senior Team Project Fall Semester 1999 Department of Computer Science Univers
1Advanced Linux ThreadsSenior Team ProjectFall
Semester 1999Department of Computer
ScienceUniversity of San Francisco
2Contents
- Introduction to concurrent programming
- Current thread implementations
- Researchs goals
- Designs issues
- Approaches
- Implementation
- Benchmarks
- Acknowledgement
3Introduction to Concurrent Programming
- Concurrent
- Programming
- Multiple threads of control executing parallel
- Sequential
- Programming
- A single thread of control
- Simple structure
- Do not share resources
- Cannot utilize multi-processors
- Complex Structure
- Share resources
- Utilize multi-processors
4Processes vs. Threads
- Processes
- Poor communication
- Heavy-weight
- Poor performance
- Threads
- Tight communication
- Light-weight
- Fast performance
5Thread Implementation Techniques
- Kernel-level Threads
- Light-weight processes with shared code and data
spaces - Support I/O blocking
- Slow context switch
- User-level Threads
- Multiplexing threads within a single process
- No blocking support
- Fast context switch
6Example
7Disadvantages of Kernel-level Threads
- Inherent expensive context-switch time from Unix
process - No application control
- Inflexible low-level thread operations
- Hard to maintain
8Disadvantages of User-level Threads
- No I/O support from kernel when one thread
blocks, other threads in the same process block - No protection for critical section from the
kernel
9Researchs Goals
- Develop new thread systems that combine the
advantages of the two thread models - Good performance context switch time
- Tight integration between kernel and user-level
threads support I/O blocking - Maintain compatibility with standard interface
POSIX threads
- Evaluate our new threads systems
- Microbenchmarks (thread operations)
- Macrobenchmarks (multi-threaded applications)
10Design Issues
Pthread Scheduler
Library
Notify I/O events
Notify new decision
Kernel
Kernel Thread Scheduler
11Initial Approaches
- Light-weight processes
- Communication based on signal system in Unix
- Scheduler activations
- Communication based on up call technique
12Light-weight Processes
13Light-weight Processes
14Light-weight Processes
15Light-weight Processes
16Scheduler Activations
17Scheduler Activations
18Scheduler Activations
19Scheduler Activations
20Scheduler Activations
21Scheduler Activations API(public methods)
- sa_register (void) to register a VP to kernel
for SAs functionalities - sa_setblockedhandler (int handler) register the
blocking handler - sa_setunblockedhandler (int handler) register
the unblocking handler - sa_setchildstack (void childstack, long num)
- sa_resumevp (unsigned long vpid) resume a VP
22Scheduler Activations API(public methods)
23Scheduler Activations API(private methods)
- void sa_blocked_notice (void)
- void sa_unblocked_notice (void)
- void sa_getchildstack (long is_out_of_stack)
- long sa_getfreeslot (void)
(These methods reside in the kernel)
24Stack Layout of an Up-call
(when entering the block/unblock handler in
user-level space)
25Microbenchmarks
All numbers are in micro second
26Low-level Debugging Experience
- Time consuming
- - rebooting time 5-10 minutes
27Debugging Experience (cont.)
- Multi-threaded environment
- - Expected output
- address thread1 66FAFF00 address thread2
66FAFFA0 - - Actual output
- address address threathreadd12
66FA66FAFF0A00
28Race Condition
- Difficult to track rarely occur
- Difficult to debug different debugging output
for each occurrence
29Software Engineering Issues
- Violating SEs conventions
- to improve speed performance
- Lack of documentation and comments
- No book on the latest kernel
- Very few comments in the Linux kernel code
30Future Work
- Fix SMP bugs
- More microbenchmarks in other thread mechanisms
- Macrobenchmarks multi-threaded applications
- Complete the functionality of standard POSIX
threads
31Acknowledgement
- Professor Greg Benson client/supervisor
- Professor Allan Cruse debugging support
- Chin-To Kwong implementing user-level threads