Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Multithreading under windows

Author: Vincent Diepeveen

Date: 09:41:56 12/06/00

Go up one level in this thread


On December 06, 2000 at 07:50:01, Stefan Meyer-Kahlen wrote:

>On December 05, 2000 at 21:24:16, Vincent Diepeveen wrote:
>
>>On December 05, 2000 at 12:37:02, Bruce Moreland wrote:
>>
>>>On December 05, 2000 at 10:28:27, Vincent Diepeveen wrote:
>>>
>>>>this is not nonsense. blocking is GARANTUEED by windows.
>>>>See the microsoft documents on it. they GARANTUEE blocking to
>>>>prevent parallel problems.
>>>
>>>Are you telling me that if I get a mouse button click message from Windows, and
>>>do something outrageously expensive before returning from that message, that my
>>>engine threads will block until I return?
>>>
>>>bruce
>>
>>Argh damn it again i wrote something and i wrote it for nothing
>>as IE4 forgot what i wrote somehow i hit some buttons and all
>>my written text gone!
>>
>>Online writing is not my favourite thing!
>>
>>Anyway what you write here above is a generalization that doesn't
>>apply always.
>>
>>What i did was next
>>
>>  WndProc gets called as user clicks in pulldownwindow quit.
>>  then in wndproc i call function: killthecrap();
>>
>>  void KillTheCrap(HWND hwnd, ..) {
>>    ..
>>    ..("Are you sure?");
>>    ..("Are you very sure?");
>>    ..("You really don't follow my advice?");
>>    ..
>>    SendToEngine(QuitEngine); /* now the engine
>
>
>If this is done by PostMessage() you get a deadlock here as you are already in
>the MainWndProc and the thread handling the Windows messages is blocked here!
>Try SendMessage(), which might work but still I wouldn't like it.

I use something faster i use shared memory to deliver it, so
no messaging or whatever. Faster as setting a few variables
is not possible unless you want to go work at register level :)

that's also explaining why i won't port my engine to your cool
new protocol, as i already communicate using shared memory.

The only interesting things now is that the engine is actually
a stand alone engine ready to also play under winboard, on the
other hand for the windows interface i can strip it down further
as it only needs to analyze at positions!

>A general rule might be to never block this MainWndProc thread.

Exactly that's what i do right now. Never block it, you never
know what trouble happens if you block it :)

>Stefan
>
>
>
>>    gets a quit message. After it has processed it
>>    it ships acknowledgement to the enginethread
>>    that listens to the engine.
>>    The enginethread puts after getting acknowledgement
>>    the volatile variable quitengine to 1.
>>    then the enginethread quits.
>>
>>    while(!quitengine) {
>>      ;
>>    }
>>
>>  }
>>
>>Now my program was hung. I figured out that the enginethread
>>was blocked as long as my program was still in the WndProc()
>>
>>This should be pretty easy to test at home.
>>
>>Greetings,
>>Vincent



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.