Threads2
Threads2
Operating Systems
Created by:
Dr. Salem Alqahtani
Dr. Aymen Trigui
Dr. Mudassir Rafi
1
Mapping: User → Kernel Threads
• Many-to-one
• Many user-level threads → one kernel thread.
• Thread management is done by the thread library in user space, so it is
efficient.
• The entire process will block if a thread makes a blocking system call.
• Because only one thread can access the kernel at a time, multiple threads
are unable to run in parallel on multiprocessors.
• One-to-One
• One user activity → one kernel thread; Limited number of kernel threads
• Provide more conurrency than the many-to-one model by allowing another
thread to run when a thread makes a blocking system call.
• Because the overhead of creating kernel threads can burden the
performance of an application.
Mapping: User → Kernel Threads
• Many-to-Many
• Many user level threads → many kernel threads
• Multiplexer many user threads to a smaller or equal number of
kernel threads.
• The number of kernel threads may be specific to either a
particular application or particular machine.
• Aslo, when a thread performs a blocking system call, the kernel
can schedule another thread for execution
Light-Weight Process (LWP)
• Two-level threading approach
• Kernel + user
• Lightweight process (LWP): intermediate structure
• Virtual processor: can execute user-level threads
• Each LWP attaches to a kernel thread
• Multiple user-level threads → a single LWP
• Normally from the same process
• A process may be assigned multiple LWPs
• Operating System schedules kernel threads (hence, LWPs) on the CPU
LWP in Solaris (from Dave, UK)
Scheduler Activations
https://computing.llnl.gov/tutorials/pthreads/
Pthreads: Thread/Synchronization APIs