⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 me_ipc.h

📁 这是在linux环境下C++做的生产者和消费者问题
💻 H
字号:
/*******************************ipc.h**********************************************/#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>#include <sys/sem.h>#include <sys/msg.h>#define BUFSZ 256/** the functions to get the shared memary and the semaphore*/int get_ipc_id(char *proc_file,key_t key);char *set_shm(key_t shm_key,int shm_num,int shm_flag);int set_sem(key_t sem_key,int sem_val,int sem_flag);int operationP(int sem_id);int operationV(int sem_id);/** semaphore control union*/typedef union semuns{    int val;}Sem_uns;typedef struct msgbuf{    long mtype;    char *mtext;} Msg_buf;/*** the variables needed by the producers and the consumers*/key_t buff_key;/*material's key*/int i;int buff_num;int *buff_ptr;int buff_flag;key_t full_key;key_t empty_key;key_t pro_ex_key;key_t cons_ex_key;int full_value;int empty_value;int pro_ex_value;int cons_ex_value;int full_sem;int empty_sem;int pro_ex_sem;int cons_ex_sem;int sem_flag;/*********************ipc.h end******************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -