views:

60

answers:

3

I have a static library to access a Database. It has a function readMaximum().

readMaximum() reads a maximum value from DB. This function is thread safe (using mutex).

But problem is :

There are two processes A.exe and B.exe; both are compiled with the static library.

Is there any way where I can implement mutual exclusion between process A.exe and B.exe, so that when function readMaximum() is called by two processes at same time, only one is allow to go into the critical section?

PS. I would not like to change any property of the DB/Schema/Table.

+1  A: 

You could use a named semaphore. It is visible to all processes and can control that behavior.

Mark Wilkins
+1  A: 

Use CreateMutex() to created a named global mutex. Prefix the name with "Global\".

FigBug
A: 

POSIX has mutexes which can be shared among the processes.

Yogesh Arora