Thursday, July 30, 2009

Multithreading Models

  • Many-to-one

In this model, the library maps all threads to a single lightweight process Advantages: totally portable easy to do with few systems dependencies Disadvantages: cannot take advantage of parallelism may have to block for synchronous I/O there is a clever technique for avoiding it Mainly used in language systems, portable libraries

  • One-to-one

In this model, the library maps each thread to a different lightweight process Advantages: can exploit parallelism, blocking system calls Disadvantages: thread creation involves LWP creation each thread takes up kernel resources limiting the number of total threads Used in LinuxThreads and other systems where LWP creation is not too expensive.

  • Many-to-many

n this model, the library has two kinds of threads: bound and unbound bound threads are mapped each to a single lightweight process unbound threads may be mapped to the same LWP Probably the best of both worlds Used in the Solaris implementation of Pthreads (and several other Unix implementations) .

No comments: