By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

Multithread pause

P: n/a
I have a program that runs a thread for each device under test (144) the
program communicates to the Device Under Test (DUT) thru the serial port.
Originally the program only allowed 1 thread at a time to use the serial port
using CCriticalSection Lock() and Unlock. I have new hardware that includes
an 8 port serial card that connects thru a mux to a bank of DUT's so once I
select a bank(mux 1 - 18). I would like to allow all threads of a common
bank of DUT's to run while blocking all other threads. Last thread of that
bank allows next bank in. I'm thinking of using the CreateEvent &
WaitForSingleObject as my critical section enablers but am not too familiar
(Yet) with these functions. I want to make sure that maximum run priority is
given to threads communicating to bank(n). Any advice will be read and used
for personal gain. Thanks
Mar 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
>I have a program that runs a thread for each device under test (144) the
program communicates to the Device Under Test (DUT) thru the serial port.
Originally the program only allowed 1 thread at a time to use the serial
port
using CCriticalSection Lock() and Unlock. I have new hardware that
includes
an 8 port serial card that connects thru a mux to a bank of DUT's so once
I
select a bank(mux 1 - 18). I would like to allow all threads of a common
bank of DUT's to run while blocking all other threads. Last thread of
that
bank allows next bank in. I'm thinking of using the CreateEvent &
WaitForSingleObject as my critical section enablers but am not too
familiar
(Yet) with these functions. I want to make sure that maximum run priority
is
given to threads communicating to bank(n). Any advice will be read and
used
for personal gain. Thanks


Hi,

Using CreateEvent and WaitForSingleObject is a good approach.
create 1 event per mux bank, and then signal that event when appropriate.

All other threads are blocked when the active ones are running so priority
is not an issue.
if you want those threads to run at a higher priority you can slightly raise
the thread priority when you create the threads, but be careful with that as
it may make the system unresponsive, or slow to respond.

For shutting down your program you can use a global boolean that you set to
true when you are shutting down the software.
then signal all threads so they can gracefully shut down.
Another option would be to use Waitformultipleobjects to wait on the
hardware event and a shutdown event.
--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.