hello,
I know linux has this mechanism
I wanna implement it in windows 2003 and I've done some parts but one point:
writer must wait until all the reader finished.

hint: I don't want a loop in the mutex critical-section to subtract the semaphore by plural number,which can't be directly done in windows,because that's a waste of cpu-time.

it seems not that difficult but I just can't make it well.
thx in advance~~
-yogo

You can use CCriticalSection object if you are using MFC. They are less expensive than mutex.

Else, you can use InitializeCriticalSection(), EnterCriticalSection() and LeaveCriticalSection() for the same purpose.

You can use CCriticalSection object if you are using MFC. They are less expensive than mutex.

Else, you can use InitializeCriticalSection(), EnterCriticalSection() and LeaveCriticalSection() for the same purpose.

thank you for your reply~
I know what you mean by CriticalSection,unfortunately my developing evironment is C,nothing to do with MFC(sorry for not mentioning it in the post).
under pure C,the CriticalSection APIs is also available,as I know ,it is used to synchronize the operation between thread ,that is : within the process.
what I want is to operate interprocessly.(sorry for not metioning this,either :P)
that is : read_write lock between processes.
Is there any version of free source around the www?

thank you for your reply~
I know what you mean by CriticalSection,unfortunately my developing evironment is C,nothing to do with MFC(sorry for not mentioning it in the post).
under pure C,the CriticalSection APIs is also available,as I know ,it is used to synchronize the operation between thread ,that is : within the process.
what I want is to operate interprocessly.(sorry for not metioning this,either :P)
that is : read_write lock between processes.
Is there any version of free source around the www?

You can use CreateMutex() to create a named mutex. Then use WaitForSingleObject() to wait for the mutex, either for a fixed timing or infinitely. Then call ReleaseMutex() to release it.

This article has been dead for over six months. Start a new discussion instead.