Click here to Skip to main content
14,767,159 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan17-Mar-16 23:51
mveRichard MacCutchan17-Mar-16 23:51 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen18-Mar-16 18:57
MemberBram van Kampen18-Mar-16 18:57 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan18-Mar-16 23:57
mveRichard MacCutchan18-Mar-16 23:57 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen19-Mar-16 14:41
MemberBram van Kampen19-Mar-16 14:41 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan19-Mar-16 23:09
mveRichard MacCutchan19-Mar-16 23:09 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen22-Mar-16 14:34
MemberBram van Kampen22-Mar-16 14:34 
AnswerRe: Vagarities of Multiple threads in Windows Pin
leon de boer19-Mar-16 22:35
Memberleon de boer19-Mar-16 22:35 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen22-Mar-16 14:33
MemberBram van Kampen22-Mar-16 14:33 
Well,

I know and use 'volatile' (where appropriate). It is essentially a compiler directive to tread carefully when optimising.
It indicates that an agent of which the compiler is not aware can change the value unexpectedly. (which could include other threads). First of all, one can not really rely on this for synchronisation, (One does not know when the monitor thread is interrupted, and the Other thread changes the value.) Furthermore it is quite inefficient as a synchronisation method. It typically means burning CPU Cycles waiting for something to happen. The better way is to put the thread to sleep, by the use of something like WaitForSingleObject(). That means that the CPU Cycles, in stead of being burned, can be used to speed up the printing of that 40 page report in Excell that is churning in the background. By using other synchronisation objects, such as CriticalSections, Mutexes and Semaphores (I prefer the SDK Versions, as the MFC versions are really Crap in MFC42), you can Manage and Control access to sections of code and GLOBAL and STATIC variables

Note that the Stack is thread safe, as in Windows, every thread has it's own private stack. Globals and Static Data however is stored on the same heap to which is available to all threads, however, not so easily by hardware threads, but that's a (very long) story for another day

Well, I'm 99.9% Sure that the use of 'volatile' is not at issue here, but I will certainly keep your much valued comment in mind

Kind Regards Smile | :) Smile | :)

N.B.
I Like your Signature
Bram van Kampen

GeneralRe: Vagarities of Multiple threads in Windows Pin
leon de boer26-Mar-16 0:57
Memberleon de boer26-Mar-16 0:57 
QuestionOpenGL control on split MFC form Pin
Member 1228273814-Mar-16 11:08
MemberMember 1228273814-Mar-16 11:08 
AnswerRe: OpenGL control on split MFC form Pin
Richard MacCutchan15-Mar-16 0:48
mveRichard MacCutchan15-Mar-16 0:48 
QuestionDefault argument for DISP_FUNCTION_ID Pin
Member 1214953910-Mar-16 17:44
MemberMember 1214953910-Mar-16 17:44 
AnswerRe: Default argument for DISP_FUNCTION_ID Pin
Bram van Kampen16-Mar-16 16:45
MemberBram van Kampen16-Mar-16 16:45 
QuestionBoth EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
ForNow10-Mar-16 11:19
MemberForNow10-Mar-16 11:19 
AnswerRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
Bram van Kampen10-Mar-16 15:39
MemberBram van Kampen10-Mar-16 15:39 
GeneralRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
ForNow10-Mar-16 16:20
MemberForNow10-Mar-16 16:20 
GeneralRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
Richard MacCutchan11-Mar-16 4:52
mveRichard MacCutchan11-Mar-16 4:52 
AnswerRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
Richard MacCutchan10-Mar-16 22:21
mveRichard MacCutchan10-Mar-16 22:21 
AnswerRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
leon de boer19-Mar-16 22:50
Memberleon de boer19-Mar-16 22:50 
GeneralRe: Both EnumchildWindows and GetWindow return NULL for a ChildWindow modeless dialogbox Pin
ForNow20-Mar-16 13:45
MemberForNow20-Mar-16 13:45 
QuestionHow Much of WM_USER+X is used by MFC Pin
Bram van Kampen9-Mar-16 15:14
MemberBram van Kampen9-Mar-16 15:14 
AnswerRe: How Much of WM_USER+X is used by MFC Pin
Jochen Arndt9-Mar-16 22:38
professionalJochen Arndt9-Mar-16 22:38 
AnswerRe: How Much of WM_USER+X is used by MFC Pin
Richard MacCutchan9-Mar-16 23:17
mveRichard MacCutchan9-Mar-16 23:17 
GeneralRe: How Much of WM_USER+X is used by MFC Pin
Bram van Kampen10-Mar-16 15:03
MemberBram van Kampen10-Mar-16 15:03 
GeneralRe: How Much of WM_USER+X is used by MFC Pin
Richard MacCutchan10-Mar-16 22:15
mveRichard MacCutchan10-Mar-16 22:15 

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.