Hi Eliot, Bert,
as part of reading the "goToSleep" primitive I had a look at Windows and the last time I dealt with win32 API was quite some time ago so maybe I am wrong but doesn't the time slice below look like a race condition? If not what am I missing?
VM Thread Socket Read Thread
ioRelinquishProcess..
SIGNAL(pss->readSema)
-> SetEvent(vmWakeUpEvent)
ResetEvent(vmWakeUpEvent)
MsgWaitForMultipleObjects...
Couldn't we have lost the vmWakeUpEvent for the socket and then wait the full timeout? The history in Opensmalltalk-vm doesn't go far but couldn't we create the vmWakeUpEvent with the autoreset flag?
thank you
holger
Code snippets:
sqInt ioRelinquishProcessorForMicroseconds(sqInt microSeconds)
{
/* wake us up if something happens */
ResetEvent(vmWakeUpEvent);
if (WAIT_TIMEOUT ==
MsgWaitForMultipleObjects(1, &vmWakeUpEvent, FALSE,
microSeconds / 1000, QS_ALLINPUT))
int synchronizedSignalSemaphoreWithIndex(int semaIndex)
{
int result;
/* Do our job - this is now synchronized in signalSemaphoreWithIndex */
result = signalSemaphoreWithIndex(semaIndex);
/* wake up interpret() if sleeping */
SetEvent(vmWakeUpEvent);
static DWORD WINAPI readWatcherThread(privateSocketStruct *pss)
{
struct timeval tv= { 1000, 0 }; /* Timeout value == 1000 sec */
fd_set fds;
int n, doWait;
while(1) {
...
switch(pss->readWatcherOp) {
case WatchData:
/* Data may be available */
pss->sockState |= SOCK_DATA_READABLE;
SIGNAL(pss->readSema);