-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsh_tester.c
49 lines (37 loc) · 1.08 KB
/
sh_tester.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
46
47
48
49
#include "shared_memory.h"
void main(int argc,char** argv){
informacion * info;
int * sem;
int i;
info = (informacion *) crea_o_asocia_shm(14856,sem,10);
if(info == NULL){
printf("\n Tester :fallo con la memoria");
}
/*
info = (informacion *) crea_o_asocia_shm(123456,sem,10);
if(info == NULL){
printf("\n Tester :fallo con la memoria");
}
*/
printf("\n Todo guay por aqui");
for(i=0;i<5;i++){
info->contenido[i] = i;
}
for(i=0;i<5;i++){
printf("\n Valor : %d",info->contenido[i]);
}
Up_Semaforo( *info->semaforo,0, SEM_UNDO);/*Lo ponemos a 1*/
printf("\nBajamos el semaforo binario 5 segundos");
Down_Semaforo( *info->semaforo,0, SEM_UNDO);
sleep(5);
printf("\nSubimos");
Up_Semaforo( *info->semaforo,0, SEM_UNDO);
for(i=5;i<10;i++){
info->contenido[i] = i;
}
for(i=5;i<10;i++){
printf("\n Valor : %d",info->contenido[i]);
}
destruye_shm((char *)info );
printf("\n Fin del tester");
}