Ajout Exo1

This commit is contained in:
Ronan Fourneuve
2025-08-08 10:56:50 +02:00
parent 1bb411b001
commit 7e12cccab5
32 changed files with 192 additions and 0 deletions

23
ANALE-1/EXO1/conso.c Normal file
View File

@@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/shm.h>
#include "dijkstra.h"
#include "commun.h"
int main () {
int sem_prod = sem_create (CLE_SEM_PROD ,SEM);
int sem_conso = sem_create (CLE_SEM_CONSO ,0);
int shmid = shmget(CLE_MEM,MEM*sizeof(int),0644);
int* shmem = shmat(shmid,NULL,0);
for (int i = 0; i < 26; i++)
{
P(sem_conso);
char c = shmem[i%MEM];
V(sem_prod);
printf("%c",c);
}
printf("\n");
shmdt(shmem);
return 0;
}