Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

Multithread pause

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
diskDriveGuy - 20 Mar 2006 22:31 GMT
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
Bruno van Dooren - 21 Mar 2006 07:07 GMT
>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.
[quoted text clipped - 15 lines]
> 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.
Signature


Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.