close

The POSIX thread libraries are a standards based thread API for C/C++. It allows one to spawn a new concurrent process flow. It is most effective on multi-processor or multi-core systems where the process flow can be scheduled to run on another processor thus gaining speed through parallel or distributed processing.

Threads require less overhead than "forking" or spawning a new process because the system does not initialize a new system virtual memory space and environment for the process.

While most effective on a multiprocessor system, gains are also found on uniprocessor systems which exploit latency in I/O and other system functions which may halt process execution. (One thread may execute while another is waiting for I/O or some other system latency.) Parallel programming technologies such as MPI and PVM are used in a distributed computing environment while threads are limited to a single computer system. All threads within a process share the same address space. A thread is spawned by defining a function and its arguments which will be processed in the thread. The purpose of using the POSIX thread library in your software is to execute software faster.

 

Threads in the same process share:

1.  Process instructions

2.  Most data

3.  open files (descriptors)

4.  signals and signal handlers

5.  current working directory

6.  User and group id


Each thread has a unique:

1.  Thread ID

2.  set of registers, stack pointer

3.  stack for local variables, return addresses

4.  signal mask

5.  priority

6.  Return value: errno

Pthread functions return "0" if OK.

 

 

arrow
arrow
    全站熱搜

    phchiu 發表在 痞客邦 留言(0) 人氣()