A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Add more Mc Mini tests
[simgrid.git]
/
teshsuite
/
mc
/
mcmini
/
simple_semaphores_ok.c
1
#define _POSIX_C_SOURCE 200809L
2
3
#include <pthread.h>
4
#include <semaphore.h>
5
#include <stdlib.h>
6
#include <stdio.h>
7
8
sem_t sem;
9
10
int main(int argc, char* argv[]) {
11
if(argc < 2) {
12
printf("Expected usage: %s START_NUM\n", argv[0]);
13
return -1;
14
}
15
16
int start_num = atoi(argv[1]);
17
18
sem_init(&sem, 0, start_num);
19
20
for(int i = 0; i < start_num; i++) {
21
sem_wait(&sem);
22
}
23
24
sem_post(&sem);
25
sem_post(&sem);
26
sem_wait(&sem);
27
sem_wait(&sem);
28
29
sem_destroy(&sem);
30
31
return 0;
32
}