Re: Message between threads

Tech-Archive recommends: Speed Up your PC by fixing your registry



I don't understand what in the world you're trying to accomplish. Sit down
with someone who knows multi-threaded code and explain to them what's
supposed to happen, then work out what the code should do to implement
that...

The SetEvent in the communication_thread is *never executed*. It's outside
the loop which runs forever. The same is true of the status event which is
never set in algorithm_thread...

Paul T.

"wceess" <wceess@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:493B468E-CBEC-4E1B-BE0E-5FA6C7A99F6D@xxxxxxxxxxxxxxxx

Hi paul,

Just curous to know what would happen in this code

DWORD communication_thread(LPVOID lpv)
{
short int j = 0;
while(TRUE)
{
EnterCriticalSection(&csObject1);

message.failure_status = FALSE;
messages.failure_id = 0;

LeaveCriticalSection(&csObject1);

Sleep(100);
}
SetEvent(communication_event);
return 0;
}

DWORD algorithm_thread(LPVOID lpv)
{
WaitForSingleObject(communication_event, 150); // auto reset
while (TRUE)
{
EnterCriticalSection(&csObject2);

important_data = i;

LeaveCriticalSection(&csObject2);

Sleep(1000);
}

SetEvent(status_event);

return 0;
}

Will the setevent in comm can make the alg to run even though if its in
sleep for 1000 or only after say roughly 10 times this will wake up the
alg.

THanks



.



Relevant Pages

  • Re: Wait for Multiple objects
    ... Previously when i setevent k1 i waited for ... DWORD thread2(LPVOID lpv) ... The ret1 is still 87..plz need help ...
    (microsoft.public.windowsce.embedded)
  • Re: Wait for Multiple objects
    ... Now wait for single object works for both the event but ... DWORD thread2(LPVOID lpv) ... The ret1 is still 87..plz need help ...
    (microsoft.public.windowsce.embedded)
  • Re: Wait for Multiple objects
    ... Wait for both objects in the WaitForMultipleObjects, ... DWORD thread2(LPVOID lpv) ... The ret1 is still 87..plz need help ...
    (microsoft.public.windowsce.embedded)
  • Re: Wait for Multiple objects
    ... The docs for WaitForMultipleObjects ... DWORD thread2(LPVOID lpv) ... The ret1 is still 87..plz need help ...
    (microsoft.public.windowsce.embedded)