开发者

Mutual exclusion (in static library )

I have a static librar开发者_高级运维y 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.


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


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


POSIX has mutexes which can be shared among the processes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜