Multithread pause

G

Guest

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
 
B

Bruno van Dooren

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
(e-mail address removed)
Remove only "_nos_pam"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top