Latest News on this Document
1 May 1998: | The code and documentation contained herein now conforms to POSIX 1003.1c-1995. The previous version of this document is based on POSIX 1003.1c draft 4 which (AFAIK) only works on DEC OSF/1 3.2. The old code can still be downloaded here if you need it; however, the draft 4 code will no longer be maintained. The revised code described here has only been tested on Linux systems (LinuxThreads and glibc native threads). If you encounter problems or have corrections, please send an email to system. |
What are threads?
A thread is a sequence of instructions to be executed within a program. Normal UNIX processes consist of a single thread of execution that starts in main(). In other words, each line of your code is executed in turn, exactly one line at a time. Before threads, the normal way to achieve multiple instruction sequences (ie, doing several things at once, in parallel) was to use the fork() and exec() system calls to create several processes -- each being a single thread of execution.
In the UNIX operating system, every process has the following:
1. a virtual address space (ie, stack, data, and code segments)
2. system resources (eg, open files)
3. a thread of execution
These resources are private to each process; for example, processes cannot peek into one another's address space, open and close files for one another, etc. To achieve interprocesses cooperation, external channels (to the process) of communication are needed. UNIX systems provide several mechanisms for accomplishing interprocess communication (IPC), including (relevant manpages are listed in square brackets):
- UNIX files
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




