News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Multithread test code.

Started by hutch--, September 21, 2009, 01:21:16 AM

Previous topic - Next topic

hutch--

I originally designed this as 4 thread and the idea with the test was to start a set number of threads that then sit in a yielding idle loop until they poll a signal to do something. This is a technique very similar to the one Dave mentioned. It uses another idle loop in the thread code to hold the thread until all of the waiting threads have been started then it returns back to the main thread idle loop waiting for another signal.

I have kept the thread code re-entrant by using stack addressing with a structure for the flags and signal variables and this allows the thread count to be changed without having to alter the thread code.

It seems to be working OK at the moment, the layout is still a bit scruffy but its still in the experimental stage.

PS I should have noted that when you press the "1" key, wait for it to finish running the 4 threads before you either press the 1 key again OR press "2" to exit otherwise it exits the keyloop before the threads have all sent their termination signal and it loops infinitely in the exit test loop.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php