Professional Documents
Culture Documents
Note that this only works because fork() returns two completely independent copies of the original process. Each process has its own address space, with its own copies of its variables, which are completely independent of the same variables in the other process (the only exception to this is with some SysV IPC variables, but these are special cases). This independence, while providing memory protection and therefore stability, causes problems when you want to have multiple processes working on the same task/problem. Yes you can use pipes or SysV IPC, but there are still serious problems. The cost of switching between multiple processes is relatively high. There are often severe limits on the number of processes the scheduler can handle efficiently. Synchronisation variables, shared between multiple processes, are typically slow. For these reasons, and others, threads or Light Weight Processes(LWP) can be very useful. Threads share a common address space, and are often scheduled internally in a process, thereby avoiding a lot of the inefficiencies of multiple processes. One very popular API for threading an application is pthreads, also known as POSIX threads, P1003.1c, or ISO/IEC 9945-1:1990c. This API is the subject of todays tutorial. <<< Contents >>> Andrae Muys
www.cs.nmsu.edu/~jcook/Tools/pthreads/pthreads.html
1/1