<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
   <TITLE>Linux Threads Home Page: How are Linux kernel threads accessed?</TITLE>
   <META NAME="GENERATOR" CONTENT="Mozilla/3.0Gold (WinNT; U) [Netscape]">
</HEAD>
<BODY background="GraySea.gif">

<P><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 &quot;clone()&quot; 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
thread will be assigned a TID beginning with 1 (the parent). 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 SIZE=4 WIDTH="100%"></P>

<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 >
<TR>
<TD>
<CENTER><P><A HREF="CloneFlags.html"><IMG SRC="ArrowLeft.gif" ALT="[Left Arrow]" BORDER=0 HEIGHT=40 WIDTH=40></A></P></CENTER>
</TD>

<TD>
<CENTER><P><A HREF="index.html"><IMG SRC="House.gif" ALT="[Home]" BORDER=0 HEIGHT=40 WIDTH=40></A></P></CENTER>
</TD>

<TD>
<CENTER><P><A HREF="Dictionary.html"><IMG SRC="BookSearch.gif" ALT="[Book Search]" BORDER=0 HEIGHT=40 WIDTH=40></A></P></CENTER>
</TD>

<TD>
<CENTER><P><A HREF="mailto:walton@oclc.org"><IMG SRC="MailBox.gif" ALT="[Mailbox]" BORDER=0 HEIGHT=40 WIDTH=40></A></P></CENTER>
</TD>

<TD>
<CENTER><P><A HREF="Scheduling.html"><IMG SRC="ArrowRight.gif" ALT="[Right Arrow]" BORDER=0 HEIGHT=40 WIDTH=40></A></P></CENTER>
</TD>
</TR>

<TR>
<TD><A HREF="CloneFlags.html">[Previous Page]</A></TD>

<TD><A HREF="index.html">[First Page]</A></TD>

<TD><A HREF="Dictionary.html">[Dictionary]</A></TD>

<TD><A HREF="mailto:walton@oclc.org">[Email Author]</A></TD>

<TD><A HREF="Scheduling.html">[Next Page]</A></TD>
</TR>
</TABLE></CENTER>

</BODY>
</HTML>
