Page 1 of 1

Cross Platform Multi-Threading Libraries - Help needed

PostPosted: 16 Jan 2006, 18:35
by Steve Maughan
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

Re: Cross Platform Multi-Threading Libraries - Help needed

PostPosted: 16 Jan 2006, 19:43
by Ron Murawski
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

Re: Cross Platform Multi-Threading Libraries - Help needed

PostPosted: 16 Jan 2006, 20:01
by Dann Corbit

Re: Cross Platform Multi-Threading Libraries - Help needed

PostPosted: 17 Jan 2006, 08:39
by Alessandro Scotti
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.