OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [sim/] [testsuite/] [sim/] [cris/] [c/] [thread3.c] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jlechner
/* Compiler options:
2
#cc: additional_flags=-pthread
3
#notarget: cris*-*-elf
4
 
5
   To test sched_yield in the presencs of threads.  Core from ex1.c.  */
6
 
7
#include <stddef.h>
8
#include <stdio.h>
9
#include <unistd.h>
10
#include <pthread.h>
11
#include <stdlib.h>
12
 
13
static void *
14
process (void *arg)
15
{
16
  int i;
17
  for (i = 0; i < 10; i++)
18
    {
19
      if (sched_yield () != 0)
20
        abort ();
21
    }
22
  return NULL;
23
}
24
 
25
int
26
main (void)
27
{
28
  int retcode;
29
  pthread_t th_a, th_b;
30
  void *retval;
31
 
32
  retcode = pthread_create (&th_a, NULL, process, (void *) "a");
33
  if (retcode != 0)
34
    abort ();
35
  retcode = pthread_create (&th_b, NULL, process, (void *) "b");
36
  if (retcode != 0)
37
    abort ();
38
  retcode = pthread_join (th_a, &retval);
39
  if (retcode != 0)
40
    abort ();
41
  retcode = pthread_join (th_b, &retval);
42
  if (retcode != 0)
43
    abort ();
44
  printf ("pass\n");
45
  return 0;
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.