-
Notifications
You must be signed in to change notification settings - Fork 0
/
semops.h
74 lines (59 loc) · 1.09 KB
/
semops.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#include <time.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdbool.h>
#include <sys/msg.h>
#include<signal.h>
#include <sys/shm.h>
#define POP_SIZE 1000
#define sim_time 5
#define KEY 1493
#define KEYBIN 1494
#define KEYTWO 1495
#define shmkey 123
#define shmkeyB 124
#define msgkey 2001
#define msgkeyReply 2002
union semun {
int val;
struct semid_ds* buf;
unsigned short* array;
#if defined(__linux__)
struct seminfo* __buf;
#endif
};
struct MyInvites{
long mtype;
int from;
int vote;
int willsize;
}myInvite;
struct MyReplys{
long mtype;
int from;
bool reply;
int vote;
int willSize;
}myReply;
struct Groups{
int group_leader_id;
int size;
int leader_willsize;
bool closed;
int max_vote;
}group;
struct Students {
int turn;
int id;
int vote;
int groupSize;
bool group;
}student;
struct sembuf* generateReduceOp();
struct sembuf* generateWaitOp();
struct sembuf* generateIncreaseOp();