Click here to Skip to main content
15,888,590 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMultithreading question Pin
ForNow7-Jan-17 16:36
ForNow7-Jan-17 16:36 
AnswerRe: Multithreading question Pin
Daniel Pfeffer7-Jan-17 19:02
professionalDaniel Pfeffer7-Jan-17 19:02 
GeneralRe: Multithreading question Pin
harold aptroot7-Jan-17 19:52
harold aptroot7-Jan-17 19:52 
AnswerRe: Multithreading question Pin
Richard MacCutchan7-Jan-17 20:51
mveRichard MacCutchan7-Jan-17 20:51 
AnswerRe: Multithreading question Pin
leon de boer8-Jan-17 20:03
leon de boer8-Jan-17 20:03 
GeneralRe: Multithreading question Pin
Jon McKee8-Jan-17 20:58
professionalJon McKee8-Jan-17 20:58 
GeneralRe: Multithreading question Pin
ForNow8-Jan-17 22:30
ForNow8-Jan-17 22:30 
GeneralRe: Multithreading question Pin
leon de boer9-Jan-17 18:23
leon de boer9-Jan-17 18:23 
Lets see if I have got this right

The other threads won't stop until they hit a lock point. So let me imagine they are in the section of code you overlayed. They will see your overlay (which is an interrupt opcode I guess .. you transposed the real opcode out to a hold memory somewhere). However interrupts will be disabled because you are in the IRQ routine already so it then continues thru to next opcode.

I can imagine if that is the scheme you end up with two equally bad situations
1.) the other threads pull an illegal opcode if your transpose isn't the same length as the replaced opcode
2.) they pass thru the overlay missing the held opcode (they saw the interrupt request which was ignored). So anything could happen the thread missed an entire opcode.

If that is what you are doing there is no fix, you either can't have the threads going thru the same code or you need to stop the threads immediately the other threads even advancing one opcode can be fatal much less allowing them to run to next lock point.

This goes back to what I was getting at originally you need to stop the system totally in some schemes. Some processors like Arm and many microcontrollers can do that under system control for hardware debugging. The Raspberry PI which uses an ARM6/7/8 could do that for example. I fear your current schema needs a full hardware debugging setup if I understand it correctly.

Edit: Assuming above is correct I gave this a bit of thought and there is possibly a way to do this on a normal non stepable processor. You have the stacks of the threads and that contains the Program Counter for each thread. So overlay the other threads as well this time with a relative branch instruction to there current position ... get it ... will deadloop them to exactly where they are ... meeting the requirement they don't move even one opcode forward Smile | :) You don't need the event stuff at all it's just a repeat of what you do to the active thread in the interrupt overlaying a different instruction into non active threads. Just make sure you put back the opcodes in reverse order (incase two threads are in the exact same place) from within an interrupt when you want to release it back.
In vino veritas


modified 10-Jan-17 0:55am.

GeneralRe: Multithreading question Pin
ForNow9-Jan-17 18:57
ForNow9-Jan-17 18:57 
GeneralRe: Multithreading question Pin
leon de boer10-Jan-17 23:23
leon de boer10-Jan-17 23:23 
GeneralRe: Multithreading question The Code Pin
ForNow11-Jan-17 12:29
ForNow11-Jan-17 12:29 
GeneralRe: Multithreading question The Code Pin
leon de boer12-Jan-17 14:38
leon de boer12-Jan-17 14:38 
GeneralRe: Multithreading question The Code Pin
ForNow13-Jan-17 3:28
ForNow13-Jan-17 3:28 
GeneralRe: Multithreading question The Code Pin
leon de boer14-Jan-17 22:47
leon de boer14-Jan-17 22:47 
GeneralRe: Multithreading question Pin
ForNow8-Jan-17 22:56
ForNow8-Jan-17 22:56 
GeneralRe: Multithreading question Pin
Munchies_Matt23-Jan-17 6:32
Munchies_Matt23-Jan-17 6:32 
QuestionMFC ribbon designer (gallery button) Pin
Maximilien6-Jan-17 9:43
Maximilien6-Jan-17 9:43 
AnswerRe: MFC ribbon designer (gallery button) Pin
DeeEllEll30-Mar-17 4:55
DeeEllEll30-Mar-17 4:55 
QuestionIs function prototyping dead? Pin
Vaclav_6-Jan-17 5:43
Vaclav_6-Jan-17 5:43 
AnswerRe: Is function prototyping dead? Pin
Richard MacCutchan6-Jan-17 5:49
mveRichard MacCutchan6-Jan-17 5:49 
GeneralRe: Is function prototyping dead? Pin
Vaclav_6-Jan-17 16:19
Vaclav_6-Jan-17 16:19 
GeneralRe: Is function prototyping dead? Pin
Richard MacCutchan6-Jan-17 21:55
mveRichard MacCutchan6-Jan-17 21:55 
AnswerRe: Is function prototyping dead? Pin
Jochen Arndt6-Jan-17 22:17
professionalJochen Arndt6-Jan-17 22:17 
GeneralRe: Is function prototyping dead? Pin
Vaclav_7-Jan-17 4:29
Vaclav_7-Jan-17 4:29 
GeneralRe: Is function prototyping dead? Pin
Jochen Arndt8-Jan-17 20:58
professionalJochen Arndt8-Jan-17 20:58 

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.