File: trythrds.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (25 lines) | stat: -rw-r--r-- 431 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <sys/time.h>
#include <threads.h>

int worker(void* arg) {
  (void)arg;
  return 0;
}

int main() {
  thrd_t x;
  if (thrd_create(&x,worker,0)==-1)
    return 111;
  if (thrd_join(x,NULL)==-1)
    return 111;
  cnd_t c;
  mtx_t m;
  mtx_init(&m, mtx_plain);
  mtx_lock(&m);
  mtx_unlock(&m);
  cnd_init(&c);
  cnd_timedwait(&c, &m, (struct timespec[]){ [0].tv_sec=1 });
  cnd_destroy(&c);
  mtx_destroy(&m);
  return 0;
}