-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpthead.c
More file actions
21 lines (19 loc) · 817 Bytes
/
pthead.c
File metadata and controls
21 lines (19 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* * hello.c - Pthreads "hello, world" program
* */
/* $begin hello */
#include "csapp.h"
void *thread(void *vargp); //line:conc:hello:prototype
int main() //line:conc:hello:main
{
pthread_t tid; //line:conc:hello:tid
Pthread_create(&tid, NULL, thread, NULL); //line:conc:hello:create
Pthread_join(tid, NULL); //line:conc:hello:join
exit(0); //line:conc:hello:exit
}
void *thread(void *vargp) /* thread routine */ //line:conc:hello:beginthread
{
printf("Hello, world!\n");
return NULL; //line:conc:hello:return
} //line:conc:hello:endthread
/* $end hello */