c++ - Regulating IPC between two processes with mutex -
c++ - Regulating IPC between two processes with mutex -
i working on project creates 2 processes , want regulate ipc between them.
the processes created createproces function, , want utilize mutex ipc.
in linux semaphores, have read ipc in windows have utilize mutex.
in windows can't seem work. first create treads this:
createprocess(ipapplicationname, null, null, null, false, create_new_console, null, null, &startinfo, &processinfo); createprocess(ipapplicationname, null, null, null, false, create_new_console, null, null, &startinfo2, &processinfo2); the processes start normal when remove releasemutex phone call 1 process won't kept waiting in process. here process one:
volatile handle hmutex; // global hmutex object int main() { hmutex=createmutex(null,false,null); while(1) { waitforsingleobject(hmutex,infinite); printf("thread writing database...\n"); sleep(2000); releasemutex(hmutex); } homecoming 0; } in process 2 open mutex open mutex , comment releasemutex (so stuck here, testing. maintain on going):
int main() { while(1) { handle hmutex; hmutex=openmutex(mutex_all_access,false,mutexname); waitforsingleobject(hmutex,infinite); printf("thread writing database22...\n"); sleep(2000); //releasemutex(hmutex); } homecoming 0; } can tell me doing wrong?
you create anonymous mutex using createmutex, seek find name
c++ process synchronization ipc
Comments
Post a Comment