wangzhengquan
2020-05-25 0ae05b9d9caadd03190ecdaae204529be9cc9c66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include "binary_sems.h"        /* Declares our binary semaphore functions */
#include "mm.h"        /* Declares our binary semaphore functions */
 
#define SEM_KEY 0x5678
#define OBJ_PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP)
/* Two semaphores are used to ensure exclusive, alternating access
   to the shared memory segment */
 
#define WRITE_SEM 0             /* Writer has access to shared memory */
#define READ_SEM 1              /* Reader has access to shared memory */
 
struct Item
{
    int pic;
    int info;
    
};