#include #include #include #define _UNUSED(v) v = v typedef struct _TESTSTRUCT { int nCounter1; int nCounter2; }TESTSTRUCT, *LPTESTSTRUCT; typedef const TESTSTRUCT *LPCTESTSTRUCT; #define _UUID_TESTSTRUCT "8c2e723a-5556-4d90-b5ed-bba8575b6f28" int main(int argc, char *argv[]) { static HSHM hShm = NULL; LPTESTSTRUCT p = NULL; _UNUSED(argc); _UNUSED(argv); hShm = GfaIpcAcquireSHM(_UUID_TESTSTRUCT, sizeof(TESTSTRUCT), 1, "Teststruct"); if(hShm) { p = (LPTESTSTRUCT)GfaIpcAcquirePointer(hShm); GfaIpcLockSHM(hShm); printf("In Lock 1!\n"); GfaIpcLockSHM(hShm); printf("In Lock 2!\n"); sleep(10); GfaIpcUnlockSHM(hShm); printf("Out of Lock 2!\n"); sleep(2); GfaIpcUnlockSHM(hShm); printf("Out of Lock 1!\n"); GfaIpcReleasePointer(hShm, p); GfaIpcReleaseSHM(hShm); } return 0; }