Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
5
Добавлен:
26.05.2014
Размер:
1.09 Кб
Скачать
#include <stdio.h>
#include <sys/types.h>
#include <sys/sem.h>
#include <sys/ipc.h>
#include <errno.h>
#include <string.h>
#include "bank.h"
#define NUM 3

int ust_free=18, ust_all=18, ust_need[NUM]={4,6,8}, ust_videl[NUM]={2,3,2}, ust_ost[NUM]={2,3,6};
int cantstop[NUM]={1,1,1};
int pr;
main ()
    {
    key_t key;
    int semid;
    int i;
    /* Getting key*/
    if ((key = ftok("server", 'A')) <0)
    {
	printf("Getting key.........\e[31m Fail %s \e[37m \n", strerror(errno));
	exit(1);
	
    } else {
    	printf("Getting key......... \e[32m OK \e[37m \n");
    }
    if ((semid = semget(key, 2, 0666 | IPC_CREAT)) < 0)
    {
	printf("Creating semafor........\e[31m Fail: %s \e[37m \n", strerror(errno));
	exit(1);
    } else {
    	printf("Creating semafor........\e[32m OK \e[37m \n");
    }

    if (semop(semid, &proc_wait[0],1) < 0)
    {
	printf("Waiting for client........\e[31m Fail: %s \e[37m \n", strerror(errno));
	exit(1);
    } else {
    	printf("Waiting for client........\e[32m OK \e[37m \n");
    }

exit(0);
/*ust_free=ust_all;
for (i=0; i<= NUM; i++)
{

}
*/
}
Соседние файлы в папке lab04