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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.c/] [critical-1.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Trivial test of critical sections.  */
2
 
3
/* { dg-require-effective-target sync_int_long } */
4
 
5
#include <omp.h>
6
#include <sys/time.h>
7
#include <unistd.h>
8
#include <assert.h>
9
#include "libgomp_g.h"
10
 
11
 
12
static volatile int test = -1;
13
 
14
static void function(void *dummy)
15
{
16
  int iam = omp_get_thread_num ();
17
  int old;
18
 
19
  GOMP_critical_start ();
20
 
21
  old = __sync_lock_test_and_set (&test, iam);
22
  assert (old == -1);
23
 
24
  usleep (10);
25
  test = -1;
26
 
27
  GOMP_critical_end ();
28
}
29
 
30
int main()
31
{
32
  omp_set_dynamic (0);
33
 
34
  GOMP_parallel_start (function, NULL, 3);
35
  function (NULL);
36
  GOMP_parallel_end ();
37
 
38
  return 0;
39
}

powered by: WebSVN 2.1.0

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