|
||||||||||||
|
|
How are Linux kernel threads accessed? Since kernel threads are individual tasks with various shared parts,the question naturally arises: how are the threads associated with theparent and how are they accessed? There appear to be two ways: throughthe language or through the kernel. Language Access There exist several languages that support threads intrinsicly: Modula-3,Java, Python 1.4, Smalltalk/X, Objective-C/Gnustep and Ada. Each have languageelements to program/access individual threads. All of these languages areavailable to the Linux community. However, they only support user threads;no "clone()" calls are made to the new Linux kernels. There appearsto be effort, however, in revising these languages to support the newerkernels. Kernel Access Each PID is 32bits, wrapping (modulus) at 30000 for really old software.If CLONE_PID is not used, each thread will get its own PID likeany other process. However, if the PID is to be shared, the kernel usesthe upper 16bits to assign the thread ID (TID) [please note that this isprobably not in the 2.0.* kernel version; we'll see it in 2.1.*for sure.] Furthermore, each process has at least one thread (the parent). Eachthread 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. Supposean app has three threads (parent and two task managers) and the threadsshare 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 taskcould be addressed with 0x00001234 (note that the first four digits arezero masking the TIDs). 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 accessingthe whole task at once). However a shorthand has been proposed: PID.TID(e.g. 46.2 would be the second thread of PID 46).
| |||||||||||
|
||||||||||||