📄 shmipc.h
字号:
//name:shmipc.h#ifndef _SHMIPC_H#define _SHMIPC_H#include "head.h"#include "queue.h"#include "work.h"#include <sys/ipc.h>#include <sys/shm.h>#include <time.h> // timespec{} for pselect() #include <fcntl.h> // for nonblocking #include <unistd.h>#include <limits.h> // PIPE_BUF #include <signal.h>#include <sys/mman.h>#include <sys/wait.h>#include <sys/stat.h> // for S_xxx file mode constants #include <sys/time.h> // timeval{} for select() #include <semaphore.h>#define MESGSIZE 1024 // max #bytes per message, incl. null at end #define NMESG 1000 // max #messages#define SHMOBJECT "/pbuffer" //共享内存对象//#define BUFFERSIZE 1024*1204*10 //共享内存长度// struct stored in shared memory #define TERMINALNUMBER 5typedef struct shmstr{ sem_t mutex __attribute__((packed)); // three Posix memory-based semaphores sem_t nempty __attribute__((packed)); sem_t nstored __attribute__((packed)); sem_t noverflowmutex __attribute__((packed)); // mutex for noverflow counter sem_t rearmutex __attribute__((packed)); sem_t frontmutex __attribute__((packed)); sem_t usedlenmutex __attribute__((packed)); // mutex for usedlen counter long nput __attribute__((packed)); // index into msgoff[] for next put 数据 包个数 long noverflow __attribute__((packed)); // #overflows by senders long usedlen __attribute__((packed)); long rear __attribute__((packed)); //head pointer long front __attribute__((packed)); //tail pointer short index_rear __attribute__((packed)); //head pointer short index_front __attribute__((packed)); //tail pointer long index[NMESG] __attribute__((packed)); //0msgoff[0]是起始位置,[1]是长度[2]是标志位,高八位不用用低24位 char msgdata[BUFFERSIZE] __attribute__((packed)); // the actual messages }shmstruct;void send_share_M();int move_index_front();int shmproducer(char *msg,unsigned long len,unsigned long mark);#endif//file end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -