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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [sim/] [testsuite/] [sim/] [cris/] [c/] [thread4.c] - Blame information for rev 330

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/* Compiler options:
2
#notarget: cris*-*-elf
3
#cc: additional_flags=-pthread
4
#output: abb ok\n
5
 
6
   Testing a pthread corner case.  Output will change with glibc
7
   releases.  */
8
 
9
#include <stddef.h>
10
#include <stdio.h>
11
#include <unistd.h>
12
#include <pthread.h>
13
#include <stdlib.h>
14
 
15
static void *
16
process (void *arg)
17
{
18
  int i;
19
 
20
  if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
21
    abort ();
22
  write (2, "a", 1);
23
  for (i = 0; i < 10; i++)
24
    {
25
      sched_yield ();
26
      pthread_testcancel ();
27
      write (2, "b", 1);
28
    }
29
  return NULL;
30
}
31
 
32
int
33
main (void)
34
{
35
  int retcode;
36
  pthread_t th_a;
37
  void *retval;
38
 
39
  retcode = pthread_create (&th_a, NULL, process, NULL);
40
  sched_yield ();
41
  sched_yield ();
42
  sched_yield ();
43
  sched_yield ();
44
  retcode = pthread_cancel (th_a);
45
  retcode = pthread_join (th_a, &retval);
46
  if (retcode != 0)
47
    abort ();
48
  fprintf (stderr, " ok\n");
49
  return 0;
50
}

powered by: WebSVN 2.1.0

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