forked from nih-at/libzip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
race.c
45 lines (34 loc) · 914 Bytes
/
race.c
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <zip.h>
#include <pthread.h>
void * unzipperTest(void * unused) {
int error = 0;
zip_t * archive = zip_open("../../regress/cm-default.zip", ZIP_RDONLY | ZIP_CHECKCONS, &error);
if (error) {
fprintf(stderr, "Error opening zip file\n");
} else {
zip_discard(archive);
}
return NULL;
}
// valgrind --tool=helgrind --vgdb=no --read-inline-info=yes --fair-sched=yes --suppressions=../../examples/helgrind.supp ./race
int main() {
pthread_t t1;
pthread_t t2;
if (pthread_create(&t1, NULL, unzipperTest, NULL)) {
fprintf(stderr, "Error creating thread\n");
return 1;
}
if (pthread_create(&t2, NULL, unzipperTest, NULL)) {
fprintf(stderr, "Error creating thread\n");
return 1;
}
if (pthread_join(t1, NULL)) {
fprintf(stderr, "Error joining thread 1\n");
return 2;
}
if (pthread_join(t2, NULL)) {
fprintf(stderr, "Error joining thread 2\n");
return 2;
}
return 0;
}