?? threads-faq.html
字號:
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="http://turnercom.com/jdk/linux3.html">[Documentation]</A>
<A HREF="http://turnercom.com/jdk/jkthread-1.1.tar.gz">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>Non-standard</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>This is an experiment with the Linux 2.0 clone() call to implement
usable kernel threads in a user program. These jkthreads have an API that
has NOTHING to do with pthreads or Win32 threads or BeBox threads. </TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL (? Source is included)</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>LinuxThreads</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD><A HREF="mailto:Xavier.Leroy@inria.fr">Xavier Leroy</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="http://pauillac.inria.fr/~xleroy/linuxthreads/">[Documentation]
</A><A HREF="ftp://ftp.inria.fr/INRIA/Projects/cristal/Xavier.Leroy/linuxthreads.tar.gz">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>POSIX 1003.1c</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>LinuxThreads is an implementation of the Posix 1003.1c thread package
for Linux. Unlike other implementations of Posix threads, LinuxThreads
provides kernel-level threads: threads are created with the new clone()
system call and all scheduling is done in the kernel.</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GNU LGPL</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>LWP</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD><A HREF="mailto:jsc@doc.ic.ac.uk">Stephen Crane</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD>[Documentation] <A HREF="ftp://gummo.doc.ic.ac.uk/rex/lwp.tar.gz">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>Non-standard</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>A small portable lightweight process library for sun[34], mips-ultrix,
386BSD, HP-UX and <B>Linux</B>. (Man pages included)</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>PCthreads</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD><A HREF="mailto:mtp@big.aa.net">Michael T. Peterson</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="http://www.aa.net/~mtp/PCthreads.html">[Documentation] </A><A HREF="ftp://sunsite.unc.edu:/pub/Linux/devel/lang/c/pthreads-1.0.tar.gz">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>POSIX 1003.1c</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>User-space pthreads library; includes non-blocking select(), read(),
and write(). Man pages included. Requires <A HREF="#DCEthreads">DCEThreads</A>.</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL (? Source is included)</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>Provenzano Pthreads</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD><A HREF="mailto:proven@mit.edu">Christopher A. Provenzano</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="http://www.mit.edu:8001/people/proven/pthreads.html">[Documentation]
</A><A HREF="ftp://sipb.mit.edu/pub/pthreads">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>POSIX 1003.1c subset (lacks thread cancellation)</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>User-space pthreads library distributed with Linux libc source but
may not be built by default.</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL (?)</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>QuickThreads</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD>David Keppel</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="ftp://ftp.cs.washington.edu/tr/1993/05/UW-CSE-93-05-06.PS.Z">[Documentation]
</A><A HREF="ftp://ftp.cs.washington.edu/pub/qt-001.tar.Z">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>Non-standard</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>A portable user-space threads package. Documentation written in PostScript.</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>Freeware (source).</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>Radke Threads</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD><A HREF="mailto:Thomas.Radke@informatik.tu-chemnitz.de">Thomas Radke</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="ftp://ftp.tu-chemnitz.de/pub/Local/informatik/linux">[Documentation]
</A><A HREF="ftp://ftp.tu-chemnitz.de/pub/Local/informatik/linux/nthreads.tgz">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>API:</TD>
<TD>Non-standard</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>User-level threads package included with patches to Linux kernel to
support kernel threading. (Includes man pages)</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL (? Source is included)</TD>
</TR>
</TABLE>
<P>
<HR></P>
<P><A NAME="ThreadAccess"></A><FONT SIZE=+3>How are Linux kernel threads
accessed?</FONT></P>
<UL>
<P>Since kernel threads are individual tasks with various shared parts,
the question naturally arises: how are the threads associated with the
parent and how are they accessed? There appear to be two ways: through
the language or through the kernel.</P>
</UL>
<P>Language Access</P>
<UL>
<P>There exist several languages that support threads intrinsicly: Modula-3,
Java, Python 1.4, Smalltalk/X, Objective-C/Gnustep and Ada. Each have language
elements to program/access individual threads. All of these languages are
available to the Linux community. However, they only support user threads;
no "clone()" calls are made to the new Linux kernels. There appears
to be effort, however, in revising these languages to support the newer
kernels.</P>
</UL>
<P>Kernel Access</P>
<UL>
<P>Each PID is 32bits, wrapping (modulus) at 30000 for really old software.
If CLONE_PID is <B>not</B> used, each thread will get its own PID like
any other process. However, if the PID is to be shared, the kernel uses
the upper 16bits to assign the thread ID (TID) [please note that this is
probably <B>not</B> in the 2.0.* kernel version; we'll see it in 2.1.*
for sure.]</P>
<P>Furthermore, each process has at least one thread (the parent). Each
new thread will be assigned a TID beginning with 1. A TID of 0 (e.g. 0x0000FFFF
mask) will address all threads within a process. Suppose an app has three
threads (parent and two task managers) and the threads share the parent's
PID. Suppose, the PIDs for each might be 0x00011234 (parent), 0x00021234
(child thread #1) and 0x00031234 (child thread #2). Each thread can be
accessed or signaled individually -or- the whole task could be addressed
with 0x00001234 (note that the first four digits are zero masking the TIDs).</P>
<P>It is the intent that the long format will work with existing apps.
And, older apps that signal the whole task will still work (by accessing
the whole task at once). However a shorthand has been proposed: PID.TID
(e.g. 46.2 would be the second thread of PID 46).</P>
</UL>
<P>
<HR></P>
<P><A NAME="SystemCall"></A><FONT SIZE=+3>Is there a system call I can
use to access kernel threads?</FONT></P>
<UL>
<P>Recent versions of glibc has clone() defined thus:</P>
</UL>
<UL>
<P><TT>int clone(int (*fn)(), void **stack, int flags, int argc,... /*
args */); </TT></P>
<UL>
<UL>
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=5 >
<TR>
<TD><TT>fn</TT></TD>
<TD><TT>The thread routine</TT></TD>
</TR>
<TR>
<TD><TT>stack </TT></TD>
<TD><TT>The thread's stack</TT></TD>
</TR>
<TR>
<TD><TT>flags </TT></TD>
<TD><TT>Flags as defined above</TT></TD>
</TR>
<TR>
<TD><TT>argc </TT></TD>
<TD><TT>number of remaining parameters</TT></TD>
</TR>
<TR>
<TD><TT>/* args */</TT></TD>
<TD><TT>the parameters expected by the thread.</TT></TD>
</TR>
</TABLE>
</UL>
</UL>
</UL>
<P>
<HR></P>
<P><A NAME="ThreadScheduling"></A><FONT SIZE=+3>Are there ways currently
to determine thread schedule ordering?</FONT></P>
<UL>
<P>Not 100%. There are realtime extensions in the 2.0.0 kernels that will
grant finer-tuned control over threads/tasks via `sched_setscheduler'.
[Author's note: I have no idea about this. I will update this as I get
more info.]</P>
</UL>
<P>
<HR></P>
<P><A NAME="LanguageSupport"></A><FONT SIZE=+3>Are there languages that
support threads?</FONT></P>
<UL>
<P>Currently, Ada, Modula-3, Python 1.4, SmallTalk/X, Objective-C/ Gnustep
and Java have intrinsic language elements to support threads (for example,
Ada has the 'Select' statement which is a "thread guard"). However,
the Linux implementations of these languages do not yet support the new
kernel threads.</P>
<P>Naturally, C and C++ can make calls to spawn threads and processes,
but there are no language elements to support them beyond these system
calls. See below for a listing of available languages:</P>
</UL>
<P>Threading Languages</P>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Titles:</FONT></TD>
<TD><FONT SIZE=+2>Ada/Ed</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD>New York University</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD>[Documentation] <A HREF="http://sunsite.unc.edu/pub/Linux/devel/lang/ada/INDEX.html">[Source]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Newsgroup:</TD>
<TD><A HREF="news:comp.lang.ada">comp.lang.ada</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Threads Lib:</TD>
<TD>LinuxThreads</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>Ada/Ed is a translator-interpreter for Ada. It is intended as a teaching
tool and does not have the capacity, performance or robustness of commercial
Ada compilers. Ada/Ed was developed as a long-range project in language
definition and software prototyping.</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>Gnat</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD>New York University</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="http://www.ocsystems.com/xada/gnat1.html">[Documentation]
[Source]</A><A HREF="http://sunsite.unc.edu/pub/Linux/devel/lang/ada/INDEX.html">[SVGA
Bindings]</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Newsgroup:</TD>
<TD><A HREF="news:comp.lang.ada">comp.lang.ada</A></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Threads Lib:</TD>
<TD>LinuxThreads</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Description:</TD>
<TD>GNAT is the Ada 95 compiler produced by a collaboration between a team
at New York University and the Free Software Foundation, 'owner' of the
GNU software project.</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>License: </TD>
<TD>GPL</TD>
</TR>
</TABLE>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=5 WIDTH="100%" >
<TR>
<TD ALIGN=RIGHT><FONT SIZE=+2>Title:</FONT></TD>
<TD><FONT SIZE=+2>Guavac & Kaffe (Java)</FONT></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Author:</TD>
<TD>???</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Repositories:</TD>
<TD><A HREF="http://http.cs.berkeley.edu/~engberg/guavac/">[Guavac Documentation]</A>
<A HREF="http://web.soi.city.ac.uk/~tim/kaffe/kaffe.html">[Kaffe Documentation]</A>
<P><A HREF="ftp://summit.stanford.edu/pub/guavac/">[Gauvac Source]</A>
<A HREF="ftp://ftp.sarc.city.ac.uk/pub/kaffe/">[Kaffe Source]</A></P>
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Newsgroup:</TD>
<TD></TD>
</TR>
<TR>
<TD ALIGN=RIGHT>Threads Lib:</TD>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -