Ajout Exo1
This commit is contained in:
21
ANALE-1/EXO1/prod.c
Normal file
21
ANALE-1/EXO1/prod.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#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_prod);
|
||||
shmem[i%MEM] = 'a'+i;
|
||||
V(sem_conso);
|
||||
}
|
||||
shmdt(shmem);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user