And the techniques used in the synchronization of

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

and the techniques used in the synchronization of threads are, in general, the same as for the synchronization of processes. 2. Thread Implementation Approaches There are two broad categories of thread implementation: user-level threads ( ULTs ) and kernel-level threads ( KLTs ) (known as kernel-supported threads or lightweight processes). 2.1 Pure User Level Threads (Many to One (M:1) model for CPU scheduling) Figure 2.1: Pure user level threads (many to one mapping model) An M:1 model implies that all application-level threads map to a single kernel-level scheduled entity; the kernel has no knowledge of the application threads. With this approach, context switching can be done very quickly and, in addition, it can be implemented even on simple kernels which do not support threading. One of the major drawbacks however is that it cannot benefit from the hardware acceleration
Image of page 4

Subscribe to view the full document.

5 on multi-core processors or multi-processor computers: there is never more than one thread being scheduled at the same time. It is used by GNU Portable Threads and Solaris Green Thread. In a pure ULT facility, all of the work of thread management is done in user address space (by application and threads library) and the kernel is not aware of the existence of threads. Any application can be programmed to be multithreaded by using a threads library, which is a package of routines for ULT management. The threads library contains code for creating and destroying threads, for passing messages and data between threads, for scheduling thread execution, and for saving and restoring thread contexts. By default, an application begins with a single thread and begins running in that thread. This application and its thread are allocated to a single process managed by the kernel. At any time that the application is running (the process is in the Running state), the application may spawn a new thread to run within the same process. Spawning is done by invoking the spawn utility in the threads library. Control is passed to that utility by a function call. The threads library creates a data structure (in user address space) for the new thread and then passes control to one of the threads within this process that is in the Ready state, using some scheduling algorithm. When control is passed to the library, the context of the current thread is saved, and when control is passed from the library to a thread, the context of that thread is restored. The context essentially consists of the contents of user registers, the program counter, and stack pointers. Figure 2.2: Relationships between ULT States and Process States All the activities for thread management take place in user space and within a single process. The kernel is unaware of this activity. The kernel continues to schedule the process as a unit and assigns a single execution state (Ready, Running, Blocked, etc.) to that process.
Image of page 5
Image of page 6
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