some-usable-scripts/C_Language/TP_SYS/tp_sema/consommateur.c

40 lines
648 B
C
Raw Normal View History

2011-03-17 16:37:36 +01:00
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
2011-03-19 12:29:52 +01:00
#include <sys/types.h>
#include <sys/ipc.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/sem.h>
#include "consommateur.h"
#include "types.h"
2011-03-19 12:29:52 +01:00
#include "sema.h"
#include "constantes.h"
2011-03-17 16:37:36 +01:00
int main( int argc, char **argv)
{
2011-03-19 12:29:52 +01:00
if(argc < 2) { printf("Usage : %s numIPC\n", argv[0]); exit(EXIT_FAILURE); }
key_t clef = (key_t) atoi(argv[1]);
MEMP memoireP;
memoireP.tete = 0;
memoireP.queue = 0;
int semid;
semid = creat_sem( clef, MAX_PROD);
if(semid >= 0)
{
2011-03-17 17:31:26 +01:00
2011-03-19 12:29:52 +01:00
sleep(10);
del_sem(clef);
}
2011-03-17 17:31:26 +01:00
2011-03-17 16:37:36 +01:00
exit(EXIT_SUCCESS);
}