The threads library is a set of application level

This preview shows page 6 - 8 out of 33 pages.

The threads library is a set of application-level functions shared by all applications. There are two distinct disadvantages of ULTs compared to KLTs: 1. In a typical OS, many system calls are blocking. As a result, when a ULT executes a system call, not only is that thread blocked, but also all of the threads within the process are blocked. 2. In a pure ULT strategy, a multithreaded application cannot take advantage of multiprocessing. A kernel assigns one process to only one processor at a time. Therefore, only a single thread within a process can execute at a time. In effect, we have application-level multiprogramming within a single process. While this multiprogramming can result in a significant speedup of the application, there are applications that would benefit from the ability to execute portions of code simultaneously. There are ways to work around these two problems. For example, both problems can be overcome by writing an application as multiple processes rather than multiple threads. But this approach eliminates the main advantage of threads: Each switch becomes a process switch rather than a thread switch, resulting in much greater overhead. Another way to overcome the problem of blocking threads is to use a technique referred to as jacketing . The purpose of jacketing is to convert a blocking system call into a non-blocking system call. For example, instead of directly calling a system I/O routine, a thread calls an application-
Image of page 6

Subscribe to view the full document.

7 level I/O jacket routine. Within this jacket routine is code that checks to determine if the I/O device is busy. If it is, the thread enters the Blocked state and passes control (through the threads library) to another thread. When this thread later is given control again, the jacket routine checks the I/O device again. 2.2 Summary on ULTs (M:1 model) User-level threads (ULT): Many-to-one thread mapping Implemented by user-level runtime libraries Create, destroy, schedule, synchronize threads at user-level Saving and restoring thread contexts OS is not aware of user-level threads OS thinks each process contains only a single thread of control Advantages Does not require OS support; Portable o Can run on any OS Can tune scheduling policy to meet application demands o You can create several scheduling policies in your thread library o Use one that is appropriate for your users (e.g. FIFO, SJF), rather than using a general purpose scheduler o Unfortunately: cooperative scheduling (non-preemptive). Why? Lower overhead thread operations since no system calls o Thread switching does not require kernel mode o All thread management data structures in user address space Disadvantages Cannot utilize multiprocessors o OS assigns one process to only one processor at a time o In ULT scheme, OS only manages processes Entire process blocks when one thread blocks o Your thread library does not know if a read file operation will block (perform I/O to the disk) or not (read from memory).
Image of page 7
Image of page 8
You've reached the end of this preview.
  • Spring '12
  • GwangS.Jung

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern