Rss Feed
Showing posts with label OS5. Show all posts
Showing posts with label OS5. Show all posts
THREAD LIBRARY

[ ] Thread Library schedules user-level threads to run on LWP
[ ] Thread management done by user-level Threads Library
[ ] The Thread Library is responsible for scheduling user threads on the available schedulable entities; this makes context switching of threads very fast, as it avoids system calls. However, this increases complexity and the likelihood of priority inversion, as well as suboptimal scheduling without extensive (and expensive) coordination between the userland scheduler and the kernel scheduler.
Multi - threading Models





Many-to-One Model



[ ]Many user-level threads mapped to single kernel thread





* Thread management is done in user space




* Blocking problem




* No support for running in parallel on MP




* Used on systems that do not support kernel threads.




* Green-threads library in Solaris 2





One-to-One Model
[ ]Each user-level thread maps to a kernel thread


* Creating a user thread requires creating the corresponding kernel thread


* Overhead


* Restrict the number of threads supported by the OS


•Examples


* Windows NT/2000


* OS/2

Many-to-Many Model

[ ] Multiplex many user-level threads to a smaller or equal number of kernel threads

[ ] Allows many user level threads to be mapped to many kernel threads.

[ ] Allows OS to create a sufficient number of kernel threads.

•Examples

* Solaris 2, IRIX, HP-UX, Tru64 UNIX

* Windows NT/2000 with the ThreadFiber package


Kernel Thread
[ ] Kernel maintains context information for the process and the threads
[ ] Supported by the Kernel
[ ] Slower to create and manage threads than are user threads
[ ] If a thread performs a blocking system call, then the kernel can schedule another thread in the application for execution.
[ ] Multiple threads are able to run in parallel on multiprocessors.
[ ] Scheduling is done on a thread basis
[ ] Slower to create and manage
[ ] If a thread performs a blocking system call, the kernel can schedule another thread in the application for execution
[ ] Can take advantage of a multi-processor environment
Examples
{}Windows 95/98/NT/2000
{}Solaris
{}Tru64 UNIX
{}BeOS
{}Linux

Thread

[ ] Lightweight process (LW)

[ ] Basic unit of CPU utilization

[ ] A thread comprises a thread ID, a program counter, a register set, and a stack

[ ] A thread shares with other threads belonging to the same process its code section, data section, and other OS resources, such as open files and signals

[ ] A process with multiple threads can do more than one task at a time

Single-Threaded Process

Single threaded programs have one path of execution, and multi-threaded programs have two or more paths of execution. Single threaded programs can perform only one task at a time, and have to finish each task in sequence before they can start another. For most programs, one thread of execution is all you need, but sometimes it makes sense to use multiple threads in a program to accomplish multiple simultaneous tasks.

Multi-Threaded Process

Multithreading as a widespread programming and execution model allows multiple threads to exist within the context of a single process. These threads share the process' resources but are able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.

Multithreading computers have hardware support to efficiently execute multiple threads. These are distinguished from multiprocessing systems (such as multi-core systems) in that the threads have to share the resources of single core: the computing units, the CPU caches and the translation lookaside buffer(TLB). Where multiprocessing systems include multiple complete processing units, multithreading aims to increase utilization of a single core by leveraging thread-level as well as instruction-level parallelism. As the two techniques are complementary, they are sometimes combined in systems with multiple multithreading CPUs and in CPUs with multiple multithreading cores.

User Threads
[ ] Thread management done by user-level threads library
[ ] No support from the kernel (The kernel is not aware of the existence of threads)
[ ] Fast to create and manage
[ ] Block all threads for a blocking system call if the kernel is single threaded
[ ] Cannot take advantage of multi-processors
 Three primary thread libraries:
 POSIX Pthreads
 Win32 threads
 Java threads

BENEFITS OF MULTITHREADED PROGRAMMING

BENEFITS

 Responsiveness

 Resource Sharing

 Economy

 Utilization of MP Architectures