User thread

from Wikipedia, the free encyclopedia

As a user thread (also users thread written), occasionally User Level -Thread and z. B. under Windows Fiber ( see below ) called, in computer science a certain way of running programs or program parts in an interlinked manner. The functionality is not implemented directly in the kernel (as is the case with a kernel thread ), but in a separate program library that is located in userspace . This enables a context change (task switching) between the user threads without complex system calls, which means that context changes are significantly faster than between kernel threads or processes .

Scheduling

Since the user threads within a kernel thread are in principle not executed simultaneously ([pseudo-] parallel), but only one after the other, the user threads cannot be sensibly distributed over several processors . Since the operating system does not know anything about the existence of the user threads, the scheduling (timing control) of the user threads must be done by the program itself or by the program library used. Thereby, cooperative scheduling is practically always operated and not preemptive (from English preemptive , 'privileged'). The user threads must therefore give up control of their own accord.

However, this is problematic if one of the user threads makes a blocking system call . The fact that this user thread is blocked makes it impossible for it to pass control to another user thread - in this way the entire program is blocked. However, this problem can be circumvented in that the library used provides substitute functions for the user thread. The library then only uses non-blocking system calls of the operating system, which the operating system must provide.

Different point of view

The concept of user threads can also be seen as an extension of the concepts of procedures or functions in corresponding programming languages . From this point of view, a user thread corresponds to a procedure that is called from another point (via the explicit scheduling of precisely this user thread). However, such a procedure does not necessarily return to the caller's control flow at exactly one point, but can rather "return" more than once and to different points via its self-performed scheduling. This view is also reflected in the way in which user threads are declared in some systems - namely as a separate procedure for each user thread.

Implementations

User thread libraries are available under many operating systems, but interpreters can also support user threads. The naming of the user threads differs depending on the implementation .

Windows

Microsoft calls the user threads it offers (since Windows 98 ) under Windows Fibers . The English word fiber ( dt. ' Fiber ' → ' fiber ') can be used here as a reference to the natural relationship of a thread - d. H. a thread - to be understood as a fiber / fiber: A fiber / fiber is thinner and simpler than a thread (thread); a thread can be spun from several individual fibers. A thread can be converted to a fiber under Windows and vice versa.

Linux

In Linux, for example, the LinuxThreads and GNU Portable Threads libraries provide user threads . LinuxThreads is no longer being developed, however, and its successor, the Native POSIX Thread Library (NPTL), is no longer a pure user space library.

Solaris

The naming convention on Solaris differs from that on Windows and Linux . A kernel thread is here as a lightweight process ( Engl. ; → see, lightweight process'. Thread (computer science) ) referred to and a user thread simply thread called.
A Solaris thread can also be associated with other lightweight processes in the same process .

Java Virtual Machine

Newer versions of the Java Virtual Machine (JVM) use, if available, the capabilities of the local operating system to make threads available to the programmer. With older versions or if the operating system does not support kernel threads , the JVM also has its own user thread functionality. This is known as the green thread . Green threads are real user threads, but still offer preemptive , priority-based scheduling , which is implemented by the JVM.

literature

Individual evidence

  1. Cprogramming.com: Introduction to Windows Programming and OpenGL. (English)
  2. Vikram Shukla: Linux threading models compared: LinuxThreads and NPTL (PDF; 50 KB, English), accessed on May 31, 2019.
  3. ^ Fabian Zabatta, Kevin Ying: A Thread Performance Comparison: Windows NT and Solaris on A Symmetric Multiprocessor. 2nd USENIX Windows NT Symposium, August 3rd – 5th, 1998. In: usenix.org. USENIX Association, April 10, 2002, accessed February 6, 2014 .
  4. ^ Glenn L. Vanderburg et al .: Tricks of the Java Programming Gurus. Archived from the original on May 25, 2009 ; accessed on April 14, 2018 (English).

Web links