469,602 Members | 1,940 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

Multithread pause

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
1 1080
>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.

Similar topics

reply views Thread by Alice | last post: by
reply views Thread by r_obert | last post: by
11 posts views Thread by Paminu | last post: by
8 posts views Thread by Wim | last post: by
2 posts views Thread by zhebincong | last post: by
5 posts views Thread by juky | last post: by
6 posts views Thread by jmartin | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.