Thread In OSs

Threads in Linux

Unlike Windows, Linux main execution element is the process. The term thread and process was used interchangeable in Linux. Linux threading has been introduced and gone under extensive development to define its characteristics aside from processes. Earlier, Linux used to mimic a thread by generating a process through the “clone” function; the copy process shared its parent memory address and other resources. This implementation suffered scheduling and inter-process communication problems that raised the need to generate a complete Linux thread module. The LinuxThread library, one of many others including NGPT and NPTL, implements the thread in the user not the kernel space by a call to “pthread_create” function. In addition, the creation involves calls to functions that initialize and set parameters for the stack size, a step that is implicitly included within the “CreateThread ” function used by Windows. Linux allows the administrator to modify the maximum number of threads created per user, a setting that is lost when the operating system reloads. Linux threading module is based on an “on-on-one” model; threads are born joined and can synchronize on other threads termination; making use of their resources which are freed once the join is complete.

A major difference between Windows threads and Linux is the priority independence of Linux threads from their parent processes. While Windows uses function calls among threads to change states, Linux uses signals to, for example, awaken a thread from its block state. Linux maintains a similar set of standards to Windows when it comes to threads termination. The “pthread_exit ” function is called by a thread to terminate it leaving the parent process as is. Terminated threads are managed as not to turn into zombies. Only one difference is that Linux uses a manager thread, which acts as a coordinator among other threads within a certain process. This thread never terminates until all other threads are killed and thus freeing all the resources allocated to the main process.

References

  1. Kavitha Varadarajan, “Port Windows IPC apps to Linux, Part 1: Processes and threads,” IBM developerWorks, 15 Apr 2005, < http://www-128.ibm.com/developerworks/linux/library/l-ipc2lin1.html > (25 Aug 2005).
  2. The MSDN Library 2006, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/thread_pools.asp
  3. Xavier Leroy, “Linuxthreads – POSIX 1003.1c kernel threads for Linux,” LinuxThread ReadMe, 1996, < http://pauillac.inria.fr/~xleroy/linuxthreads/README(1997).
  4. Sean Walton, “LinuxThreads Frequently Asked Questions, ” The Linux Documentation Project , 21 Jan 1997, < http://tldp.org/FAQ/Threads-FAQ/index.html > (21 Jan 1997)

Leave a Reply

Your email address will not be published. Required fields are marked *

*