Thread Libraries in C
Java Threads
Threads in Functional Languages
Reactive Approach
Chores and Filaments
1. Introduction
2. Rationale
3. API Overview
4. API
5. Examples
6. Related Work
7. Conclusion
8. Man Pages
|
Several thread libraries exist for C. Among them, the Pthreads
library [17] implements the POSIX standard for
preemptive threads. LinuxThreads [4] is an
implementation of Pthreads for Linux; it is based on kernel-level threads.
Quick Threads [14] provides programmers with
a minimal support for multithreading at user-space level. Basically,
it implements context-switching in assembly code, and is thus a
low-level solution to multithreading.
Gnu Portable Threads [11] (GNU Pth) is a library of purely
cooperative threads which has portability as main objective. The Next
Generation POSIX Threading project [5] proposes to extend
GNU Pth to the M:N model, with Linux SMP machines as target.
Java introduce threads at language level. Actually, threads are
generally heavily used in Java, for example when graphics or
networking is involved. No assumption is made on the way threads are
scheduled (cooperative or preemptive scheduling) wich makes Java
multithreaded systems difficult to program and to port [13]. This difficulty is pointed out by the suppression from the
recent versions of the language of the threads primitives to gain fine
control over threads [3]. A first version of
FairThreads has been proposed in the context of the Java language [7] in order to simplify concurrent programming in Java.
Threads in Functional Languages
|
Threads are used in several ML-based languages such as CML [18]. CML is preemptively scheduled and threads communication is
synchronous and based on channels. Threads are also introduced in
CAML [2]; they are implemented by time-sharing
on a single processor, and thus cannot benefit from multiprocessors
machines.
FairThreads has been recently introduced in the Bigloo [1]
implementation of Scheme. The present version only supports linked
threads, and special constructs are introduced to deal with
non-blocking I/Os.
FairThreads actually comes out from the so-called reactive approach [6]. In this approach, one basically has instants and
broadcast events. As opposite to synchronous languages [12] such as Esterel, the absence of an event during one
instant cannot be decided before the end of this very instant. As a
consequence, the reaction to the absence of one event is delayed to
the next instant. This is a way to solve so-called "causality
problems" which are raised with synchronous languages, and which are
obstacles to modularity. The Reactive-C [8]
language was the first proposal for reactive programming in C;
in this respect, FairThreads can be considered as a descendant of it.
Chores [10] and filaments [15] are small pieces of code that do not have private stack
and are never preempted. Chores and filaments are designed for
fine-grain parallelism programming on shared-memory machines. Chores
and filaments are completely executed and cannot be suspended nor
resumed. Generally, a pool of threads is devoted to execute them.
Chores and chunk-based techniques are described in details in the
context of the Java language in [9] and [13]. Automata in FairThreads are close to chores and filaments,
but give programmers more freedom for direct coding of states-based
algorithms. Automata are also related to mode automata [16] in which states capture the notion of a running
mode in the context of the synchronous language Lustre.
|