窗体顶端
POSIX Threads Programming
Blaise Barney, Lawrence Livermore National Laboratory
Table of Contents
!"
# $
%
&
'($
# $""%)%
* $%+,"
$%+,"
$%+
-(."($%+
/ ,"
,"
,"
'" ,"
0 --1-'!22)
3 !1
4 -)%)2
)2$2
5+
Abstract
%"!%6%'$6%
!"!"""7""6!"
!!26(!"22"!
8.196: "%!2
!2555'944!"
2'96
%"%!66
2%52;"2%
<$6$%+,"6
,"5+!"%%%%2
%!%""%
%2--1-!2+$!"+6
%%+!"= -%>""%
-"?@%<"2!"""!
%2!"""! %8
%2"""""6"
5 #44<%""" !%%""!2%"
Pthreads Overview
What is a Thread?
""62!2%
%"%%!A%
2"!6!2B!%B%
!"2!
!2%6!=%>%
2!%""2!%"
%"%%"%"?!"!
%"B%"CB!
7!"
A2%62%.19!
!!6@%2%2
BB2%!%
!+%6"%<
o 6!%!6%6%!
o 5
o (
o %
o )
o '(
o 7!
o 8"!
o '"
o '"
o C!%"=%@%%6!!6!6
>
UNIX PROCESS THREADS WITHIN A UNIX
PROCESS
%+!%6"
%"!%!""
%%!"""%"
++%"
!2"2"!"%
<
o '(!
o )
o '%"!!=%!"!>
o '2!"("
o !2
'6%6.19<
o 5+!%!%
o 7!2"2""!!
+'%!!
o %!"""%!"
%""
o $!%@%""
!"=!">
o 2!!C"
o B"B%2"
!"%2!
A%!%<
o %=%
"2">""""
o !"%!
o )"!"6
2@%+!":!
Pthreads Overview
What are Pthreads?
7""6!"!!
2!"22%""2
(22%"2!"!!"
!!"
(2%""2!"!6
:!2@%8.196
2!2555'944=33#>
!"2'9
6$22
!!D
22 "%!!!%
""6!"pthread.h?"%2""
C%"!2"6%libc
Pthreads Overview
Why Pthreads?
!2%":!"!
!2
!2!6
%"!$
@%2%!
8+!"62"""!%"2fork()
%%pthreads_create()%%2"
#46444!?6!2time%"6
%6!:2"
1<D+!%%!"6%'$
%"!" .(!"6
!!+
Platform
fork()
pthread_creat
e()
real user sys real user sys
AMD 2.4 GHz Opteron
(8cpus/node)
4/ *440 34 4** 43 4
IBM 1.9 GHz POWER5 p5-
575 (8cpus/node)
* 4/0 /*0 /# 4*3 4
IBM 1.5 GHz POWER4
(8cpus/node)
44# 0* / 4 44 #
INTEL 2.4 GHz Xeon (2
cpus/node)
#3# # 4/0 * 4*/ 434
INTEL 1.4 GHz Itanium2 (4
cpus/node)
## 4/ 4 * 4*/
2(EE+
- 1
- 2
前往页