On 06/22/2010 12:40 PM, Graeme Geldenhuys wrote: > Just another question. Windows gets its threading support from the Win API. > Similar for OS/2. Doesn't the Linux kernel have a similar threading API, or > do they just rely on the C library? > The "Linux Way" is more like doing separate executable than doing threads, as Linux always provided high-performance inter process communication (e.g. pipes, usable with "select()" etc.) and process starting ( "fork()" ).
Thus older Linux Kernels did not have special threading support. Threading could be done using "clone()" (instead of "fork()" ) to create processes that share some resources (e.g. memory). The kernel did not really know about the processes forming a multi-threaded application so, to provide some managing capabilities the thread library created an additional "manager thread" to do housekeeping (e.g. kill the other threads if the main thread dies). This is called "Linux Threads". Modern Kernels Kernels do provide "Native Posix Threads (NPTL) ", managing the specifics of multi-threaded processes in the Kernel itself (providing better Posix compatibility). Moreover the "FUTEX" API is provided to allow for thread synchronization to be even faster than process synchronization. The "PThread library" user-API did not change. Just using the appropriate version of glibc lets you use "Linux Threads" or "Native Posix Threads" as appropriate, and FUTEX is automatically used for Posix semaphores, if available in the arch used. Of course you can avoid using the library, do the stuff in Pascal and directly access the Kernel API, but this might be dangerous in case the API might be modified some time in the future or if it's different with different archs (e.g. some archs don't provide FUTEX). -Michael _______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
