Click here to Skip to main content
15,886,761 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Reading a comma delimited file to array Pin
Richard MacCutchan13-Feb-13 22:17
mveRichard MacCutchan13-Feb-13 22:17 
GeneralRe: Reading a comma delimited file to array Pin
Jeffrey Webster14-Feb-13 4:21
Jeffrey Webster14-Feb-13 4:21 
GeneralRe: Reading a comma delimited file to array Pin
Richard MacCutchan14-Feb-13 5:14
mveRichard MacCutchan14-Feb-13 5:14 
GeneralRe: Reading a comma delimited file to array Pin
Jeffrey Webster14-Feb-13 9:23
Jeffrey Webster14-Feb-13 9:23 
GeneralRe: Reading a comma delimited file to array Pin
David Crow14-Feb-13 5:14
David Crow14-Feb-13 5:14 
QuestionImplementing of Interruption Pin
mohammad torabi13-Feb-13 10:14
mohammad torabi13-Feb-13 10:14 
AnswerRe: Implementing of Interruption Pin
Albert Holguin13-Feb-13 11:49
professionalAlbert Holguin13-Feb-13 11:49 
AnswerRe: Implementing of Interruption Pin
Stefan_Lang15-Feb-13 3:39
Stefan_Lang15-Feb-13 3:39 
Using interrupts is something you do when your program needs to interact with hardware components that trigger these interrupts. Software can trigger only one type of interrupt, and that is by setting a timer. Your problem is not timed, it is controlled by demand, so setting a timer does not fit that problem. using a timer in this situation is like telling a home owner that instead of reacting to the door bell, he should rather check the door every 5 minutes.

I suggest you fire up your preferred search engine and search for the keywords "master slave pattern". This should provide you with lots of interesting links.

The master slave pattern is extensively used for organizing the parallelization of complex tasks. Each slave works (potentially) on its own thread, allowing it to work in parallel with its coworkers. That means telling a slave to work requires sending a message to a different thread or process. Since inter-process communication is rather slow, you should prefer the former.

In most cases it is not necessary for the slaves to live beyond the scope of their tasks. Therefore, the easiest way is to create a new thread for each slave, whenever you need one. The problem you describe assumes a fixed number of slaves however, implying that these slaves' livetimes are not linked to the tasks they work on.

In that case you need a messaging system that allows the supervisor to inform the slaves if and when they are needed, and the slaves to inform the master after they're done. The windows messaging system - as suggested above - should work well for that purpose.

The disadvantage of messages is that the master needs to keep track which of his slaves are busy. Also he'll need to queue the tasks if all slaves are busy, until one becomes available.

Since you need the ability to queue your tasks anyway, a better solution would be to just push your tasks there, always, and let your slaves pick up work items from there whenever they're idle. That way the master doesn't need to know if or who is available for work. He wouldn't even need to be informed every time a slave is done with his work item; instead, the queue could notify him when it is empty, i. e. the entire workload completed.

The only reason not to do that would be if your slaves are specialized to different tasks, but not able to decide for themselves which these are. (e. g. this may happen when the data associated with the tasks come in different formats that the slaves cannot interpret)
AnswerRe: Implementing of Interruption Pin
Shaheed Legion26-Feb-13 5:33
Shaheed Legion26-Feb-13 5:33 
QuestionLine number Add-in Pin
Krishnakumartg13-Feb-13 5:20
Krishnakumartg13-Feb-13 5:20 
QuestionRe: Line number Add-in Pin
Maximilien13-Feb-13 8:14
Maximilien13-Feb-13 8:14 
SuggestionRe: Line number Add-in Pin
Albert Holguin13-Feb-13 8:59
professionalAlbert Holguin13-Feb-13 8:59 
AnswerRe: Line number Add-in Pin
jschell13-Feb-13 10:12
jschell13-Feb-13 10:12 
QuestionCombine two windows Pin
Krishnakumartg13-Feb-13 5:16
Krishnakumartg13-Feb-13 5:16 
AnswerRe: Combine two windows Pin
prabhjot.cgc13-Feb-13 17:29
prabhjot.cgc13-Feb-13 17:29 
Questionc Pin
Member 983250613-Feb-13 2:39
Member 983250613-Feb-13 2:39 
AnswerRe: c Pin
Orjan Westin13-Feb-13 2:49
professionalOrjan Westin13-Feb-13 2:49 
AnswerRe: c Pin
Matthew Faithfull13-Feb-13 2:51
Matthew Faithfull13-Feb-13 2:51 
AnswerRe: c Pin
Richard MacCutchan13-Feb-13 3:22
mveRichard MacCutchan13-Feb-13 3:22 
QuestionRibbon To existing MFC Application Pin
002comp12-Feb-13 19:53
002comp12-Feb-13 19:53 
AnswerRe: Ribbon To existing MFC Application Pin
Richard MacCutchan12-Feb-13 22:17
mveRichard MacCutchan12-Feb-13 22:17 
QuestionCAsyncSocket exception Pin
ForNow12-Feb-13 19:47
ForNow12-Feb-13 19:47 
AnswerRe: CAsyncSocket exception Pin
Orjan Westin12-Feb-13 23:04
professionalOrjan Westin12-Feb-13 23:04 
GeneralRe: CAsyncSocket exception Pin
ForNow13-Feb-13 6:10
ForNow13-Feb-13 6:10 
Questiondisabele right click popup menu in win32 browser control Pin
venkatesh5286712-Feb-13 19:30
venkatesh5286712-Feb-13 19:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.