Click here to Skip to main content
15,898,928 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Minesweeper Game reversing hack -ASM Pin
Richard MacCutchan18-Mar-16 23:04
mveRichard MacCutchan18-Mar-16 23:04 
QuestionHow to Mix MFC Controls and OpenGL? Pin
Member 853403517-Mar-16 23:33
Member 853403517-Mar-16 23:33 
QuestionHow to perform Expression Evaluation Pin
Member 1239950317-Mar-16 8:32
Member 1239950317-Mar-16 8:32 
QuestionRe: How to perform Expression Evaluation Pin
David Crow17-Mar-16 10:11
David Crow17-Mar-16 10:11 
GeneralRe: How to perform Expression Evaluation Pin
Sascha Lefèvre17-Mar-16 10:52
professionalSascha Lefèvre17-Mar-16 10:52 
AnswerRe: How to perform Expression Evaluation Pin
Chris Losinger17-Mar-16 12:33
professionalChris Losinger17-Mar-16 12:33 
GeneralRe: How to perform Expression Evaluation Pin
Patrice T17-Mar-16 13:11
mvePatrice T17-Mar-16 13:11 
AnswerRe: How to perform Expression Evaluation Pin
Patrice T17-Mar-16 13:09
mvePatrice T17-Mar-16 13:09 
AnswerRe: How to perform Expression Evaluation Pin
Bram van Kampen22-Mar-16 14:16
Bram van Kampen22-Mar-16 14:16 
GeneralRe: How to perform Expression Evaluation Pin
David Crow23-Mar-16 2:28
David Crow23-Mar-16 2:28 
GeneralRe: How to perform Expression Evaluation Pin
Bram van Kampen25-Mar-16 13:11
Bram van Kampen25-Mar-16 13:11 
AnswerRe: How to perform Expression Evaluation Pin
Alan Balkany8-Apr-16 6:53
Alan Balkany8-Apr-16 6:53 
QuestionVagarities of Multiple threads in Windows Pin
Bram van Kampen16-Mar-16 14:36
Bram van Kampen16-Mar-16 14:36 
AnswerRe: Vagarities of Multiple threads in Windows Pin
Jochen Arndt16-Mar-16 21:59
professionalJochen Arndt16-Mar-16 21:59 
AnswerRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan16-Mar-16 23:05
mveRichard MacCutchan16-Mar-16 23:05 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen17-Mar-16 16:30
Bram van Kampen17-Mar-16 16:30 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan17-Mar-16 22:51
mveRichard MacCutchan17-Mar-16 22:51 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen18-Mar-16 17:57
Bram van Kampen18-Mar-16 17:57 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan18-Mar-16 22:57
mveRichard MacCutchan18-Mar-16 22:57 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen19-Mar-16 13:41
Bram van Kampen19-Mar-16 13:41 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Richard MacCutchan19-Mar-16 22:09
mveRichard MacCutchan19-Mar-16 22:09 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen22-Mar-16 13:34
Bram van Kampen22-Mar-16 13:34 
AnswerRe: Vagarities of Multiple threads in Windows Pin
leon de boer19-Mar-16 21:35
leon de boer19-Mar-16 21:35 
GeneralRe: Vagarities of Multiple threads in Windows Pin
Bram van Kampen22-Mar-16 13:33
Bram van Kampen22-Mar-16 13: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 boer25-Mar-16 23:57
leon de boer25-Mar-16 23:57 

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.