// Creation Date : Wed May 14 21:56:00 1997 // Last Modified : Wed May 28 20:06:33 1997 // $Id$ #ifndef _MNG_H #define _MNG_H #include #include #include #include #include //------------- Shared memories ----------------- //Note: This is not a _dynamical_ shared memory manager, it only manages // _static_ shared memory blocks, which are alloced at start and // destroyed altogether at the end. //`ShmAlloc':alloc a chunk of shared memory // `nblk': number of memory in blocks // `blksize': size of block (e.g. sizeof(double), sizeof(int), etc) //The returned pointer will be aligned to the boundary of blksize char *ShmAlloc(int nblk, int blksize); //`ShmDestroy': destroy any shared memory alloced before. #define ShmDestroy() ((void)ShmAlloc(-1,0)) //------------- Semaphores ----------------- //`SemInit':initalize the semaphore array, first `nMutex' semaphores will // behave as mutices (initally have value 1), and the rest are // general purpose semaphores (with inital value 0). void SemInit(int n, int nMutex); //`SemOp': semaphore operation (cf. `man semop') void SemOp(int i,int n); //`SemDestroy': destroy any semphores initialized. #define SemDestroy() SemInit(-1,0); //`SemUnlock/SemLock':mutex operation. #define SemUnlock(i) SemOp(i,1) #define SemLock(i) SemOp(i,-1) #endif // _MNG_H