~bkerensa/ubuntu/raring/valgrind/merge-from-deb

« back to all changes in this revision

Viewing changes to helgrind/tests/hg05_race2.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrés Roldán
  • Date: 2008-06-13 02:31:40 UTC
  • mto: (1.4.1 upstream) (2.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20080613023140-iwk33rz9rhvfkr96
Import upstream version 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* A simple race - test symaddr */
 
2
 
 
3
#include <pthread.h>
 
4
#include <unistd.h>
 
5
 
 
6
struct foo {
 
7
        struct bar {
 
8
                int plop[22];
 
9
                char biff;
 
10
        } poot[11];
 
11
};
 
12
 
 
13
static void *th(void *v)
 
14
{
 
15
        struct foo *f = (struct foo *)v;
 
16
 
 
17
        f->poot[5].plop[11]++;
 
18
 
 
19
        return 0;
 
20
}
 
21
 
 
22
int main()
 
23
{
 
24
        struct foo foo;
 
25
        pthread_t a, b;
 
26
 
 
27
        pthread_create(&a, NULL, th, &foo);     
 
28
        sleep(1);               /* force ordering */
 
29
        pthread_create(&b, NULL, th, &foo);
 
30
 
 
31
        pthread_join(a, NULL);
 
32
        pthread_join(b, NULL);
 
33
 
 
34
        return 0;
 
35
}