This commit is contained in:
Lorenzo Bianchi 2023-05-23 15:16:06 +02:00
parent 1e5e8dc896
commit efb10ef91e
6 changed files with 9 additions and 2 deletions

View File

@ -5,7 +5,7 @@
#define MAX_NAME 16
static int _MSGQID;
int _MSGQID;
#define MSG 1
#define MOVE 2

View File

@ -5,6 +5,8 @@
#define CLIENT1 1
#define SERVER 2
int _SEMID;
void setupServerSem();
int getSemid(key_t key, int size);

View File

@ -32,7 +32,6 @@ typedef enum {
PLAYER2
} tile_t;
static int _SEMID;
static int _SHMID;
static tile_t *_BOARD;

View File

@ -49,6 +49,8 @@ int main(int argc, char *argv[]){
// aperurta semaforo per connessione dei due client
printf(PSERVER "Waiting for players...\n");
printf("%d\n", _SEMID);
semOp(_SEMID, 0, 1);
semOp(_SEMID, 1, 1);

View File

@ -1,6 +1,7 @@
#include <sys/sem.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <custom_sem.h>
#include <structures.h>
@ -16,6 +17,8 @@ void setupServerSem() {
}
resetServerSem(_SEMID);
printf("%d\n", _SEMID);
}
void semOp(int semid, short sem_num, short sem_op) {

View File

@ -10,6 +10,7 @@
#include <structures.h>
#include <errExit.h>
#include <custom_msgq.h>
#include <custom_sem.h>
static int sigint_count = 2;