File: pthread.c

package info (click to toggle)
pari 2.7.2-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,976 kB
  • ctags: 12,649
  • sloc: ansic: 163,239; sh: 837; perl: 332; yacc: 201; makefile: 125
file content (22 lines) | stat: -rw-r--r-- 364 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdlib.h>
#include <pthread.h>

static __thread long counter;

void *start_routine(void *pt_val)
{
  long val = *(long *)pt_val;
  counter = val+1;
  return NULL;
}

int main(void)
{
  pthread_t thread;
  counter = 0;
  if (pthread_create(&thread, NULL, start_routine, &counter))
    exit(1);
  if (pthread_join(thread, NULL))
    exit(1);
  return 0;
}