question about concurrent access to resources

Joerg-Cyril.Hoehle at t-systems.com Joerg-Cyril.Hoehle at t-systems.com
Fri Oct 2 09:11:20 CDT 2009


Hi,

I need some information about threads and callbacks.
I already found out that:
- SetEvent delivers "asynchronously" and can unblock threads
  WaitingForMultipleObjects.  No callback is involved (which
  does not mean that the current thread cannot be preempted
  by another one awakening).
  Therefore, this seems strange:
        LeaveCriticalSection(&wma->cs);
        SetEvent(wma->hStopEvent);
        EnterCriticalSection(&wma->cs);
  I mean, if you left it, anything can have happened in between
  (including close of the device).

- Likewise, notifications (to either thread or window) deliver
  asynchronously as well, to a message queue.  No callback is involved.

- OTOH functions like waveOutReset will callback into the
  applications (via Un-/PrepareBuffer etc.).
  In this example, LeaveCriticalSecion seems necessary, because
  waveOutReset does everything on the caller's thread, which
  might cause a driver to be entered recursively.
        LeaveCriticalSection(&wma->cs);
        dwRet = waveOutReset(wma->hWave);
        EnterCriticalSection(&wma->cs);
  HOWEVER, Critical sections can be re-entered by the same thread.
  They are no inner-thread protection.  Why then leave it?
  Is the Critical section adequate at all? What else is useable?

Is it allowed for an application to call waveOpen in one thread
and then call waveOut, waveStart, waveAddBuffer etc. from another one?

Is it allowed to mmioSeek/mmioRead from different threads using the
same handle?

Thanks for your help,
	Jörg Höhle



More information about the wine-devel mailing list