Cross Platform Multi-Threading Libraries - Help needed

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

Cross Platform Multi-Threading Libraries - Help needed

Postby Steve Maughan » 16 Jan 2006, 18:35

I'm actively developing Monarch once again and I've nearly completed a substantial re-write of many fundamental routines (removing color dependency and assembly code). One thing I'd like to do is to make the code more portable across platforms - especially Linux and Mac. The main obstacle to this is the multi threaded code in Monarch. I have the engine calculate in one thread and I 'listen' for input in another. I realize that I could avoid this complication and do everything in a single thread (like Fruit and Glaurung) but eventually I'd like to make Monarch multi-threaded so I decided to create a separate thread for the engine from day one. Can anyone advise me on the best way to do this?

Here are the multi-threading routines I use under Windows.

Code: Select all
   thread_handle = (HANDLE)_beginthreadex( NULL, 0, &engine_loop, NULL, 0, &threadID );
   aPriority = GetThreadPriority(GetCurrentThread());
   SetThreadPriority(thread_handle, aPriority);
   _endthreadex(0);
   WaitForSingleObject(thread_handle, INFINITE);


Are there any (free) cross-platform libraries that I can use to replace these routines? Which one would be the best fit for this purpose?

At the same time I'd also like to add a routine to measure and display at the end of the search the CPU time utilized by Monarch (like Shredder and Fruit). Is this easy? Any pointers?

All help appreciated?

Steve
Steve Maughan
 
Posts: 48
Joined: 06 Oct 2004, 17:40
Location: Florida USA

Re: Cross Platform Multi-Threading Libraries - Help needed

Postby Ron Murawski » 16 Jan 2006, 19:43

Hi Steve,

Here's some links

http://www.boost.org/doc/html/threads.html
http://sourceforge.net/projects/msdk
http://sourceforge.net/projects/reliquary

Any of these libraries should serve your purpose.

Ron
User avatar
Ron Murawski
 
Posts: 352
Joined: 26 Sep 2004, 21:50
Location: Schenectady, NY, USA


Re: Cross Platform Multi-Threading Libraries - Help needed

Postby Alessandro Scotti » 17 Jan 2006, 08:39

Hi Steve,
if you only need to create a thread and wait for it, I suggest to use CreateThread under Windows, and pthread_create for POSIX platforms.
You will find practical examples in my System library (click on the WWW button below), which definitely works on Windows, Linux and Mac.
User avatar
Alessandro Scotti
 
Posts: 306
Joined: 20 Nov 2004, 00:10
Location: Rome, Italy


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 40 guests