some thread API examples

This commit is contained in:
Remzi Arpaci-Dusseau
2019-04-23 12:12:17 -05:00
parent b4fa80ad67
commit 502a67f965
5 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
#include <stdio.h>
#include <pthread.h>
#include "common_threads.h"
void *mythread(void *arg) {
long long int value = (long long int) arg;
printf("%lld\n", value);
return (void *) (value + 1);
}
int main(int argc, char *argv[]) {
pthread_t p;
long long int rvalue;
Pthread_create(&p, NULL, mythread, (void *) 100);
Pthread_join(p, (void **) &rvalue);
printf("returned %lld\n", rvalue);
return 0;
}