Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: need help Pin
ahmedbhatti8-May-09 9:28
ahmedbhatti8-May-09 9:28 
Questionstream Pin
viliam7-May-09 9:59
viliam7-May-09 9:59 
QuestionHow to run an exe in admin mode? Pin
birajendu7-May-09 9:38
birajendu7-May-09 9:38 
AnswerRe: How to run an exe in admin mode? Pin
Madhu Nair7-May-09 9:53
Madhu Nair7-May-09 9:53 
AnswerRe: How to run an exe in admin mode? Pin
David Crow7-May-09 10:00
David Crow7-May-09 10:00 
QuestionMultithreaded code and the volatile qualifier Pin
Skippums7-May-09 9:17
Skippums7-May-09 9:17 
AnswerRe: Multithreaded code and the volatile qualifier Pin
Stuart Dootson7-May-09 10:48
professionalStuart Dootson7-May-09 10:48 
AnswerRe: Multithreaded code and the volatile qualifier Pin
cmk7-May-09 17:09
cmk7-May-09 17:09 
There is no special asm emitted for volatile variables (in x86/x64). It is used by the compiler to restrict optimizations and control instruction ordering only. As Stuart mentioned, it isn't a lot of use (by itself) in mt programming.

Normally you'd want a lock, but a quick scan of your code seems to indicate that the algorithm ensures that main() and ThreadFunc() will always be reading/writing different buffer.data[] indicies - you'd want to make sure this is true, in some sort of formal proof, before letting the code go live.

So, in your case, after ThreadFunc() writes to buffer.data[i] and releases main() to read it, the cpu cache coherency mechanism (x86/x64) will make sure that main() sees the new version of buffer.data[i] if it is running on a different core. You don't need to do anything to make this happen.

See: http://web.ics.purdue.edu/~jvaught/education/EE563_work/lecture/x86_memory_slides.pdf[^]

...cmk

The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack

Questionany problems with this code Pin
kaku_lala7-May-09 7:51
kaku_lala7-May-09 7:51 
AnswerRe: any problems with this code Pin
David Crow7-May-09 8:56
David Crow7-May-09 8:56 
QuestionHELP [modified] Pin
yunpil7-May-09 7:40
yunpil7-May-09 7:40 
AnswerRe: HELP Pin
Cedric Moonen7-May-09 7:53
Cedric Moonen7-May-09 7:53 
JokeRe: HELP Pin
sashoalm7-May-09 22:39
sashoalm7-May-09 22:39 
QuestionRe: HELP Pin
CPallini7-May-09 9:31
mveCPallini7-May-09 9:31 
AnswerRe: HELP Pin
Wes Aday7-May-09 10:15
professionalWes Aday7-May-09 10:15 
AnswerRe: HELP Pin
Hamid_RT8-May-09 0:46
Hamid_RT8-May-09 0:46 
QuestionRasGetCustomAuthData fuction not working in non admin user. Pin
birajendu7-May-09 6:41
birajendu7-May-09 6:41 
QuestionCInternetSession with Authentification Proxy Pin
sashoalm7-May-09 6:06
sashoalm7-May-09 6:06 
AnswerRe: CInternetSession with Authentification Proxy Pin
Stuart Dootson7-May-09 7:32
professionalStuart Dootson7-May-09 7:32 
GeneralRe: CInternetSession with Authentification Proxy Pin
sashoalm7-May-09 22:37
sashoalm7-May-09 22:37 
GeneralRe: CInternetSession with Authentification Proxy Pin
Stuart Dootson7-May-09 22:42
professionalStuart Dootson7-May-09 22:42 
GeneralRe: CInternetSession with Authentification Proxy Pin
sashoalm8-May-09 0:34
sashoalm8-May-09 0:34 
GeneralRe: CInternetSession with Authentification Proxy Pin
Stuart Dootson8-May-09 2:04
professionalStuart Dootson8-May-09 2:04 
GeneralRe: CInternetSession with Authentification Proxy Pin
sashoalm8-May-09 4:32
sashoalm8-May-09 4:32 
GeneralRe: CInternetSession with Authentification Proxy Pin
Stuart Dootson8-May-09 4:47
professionalStuart Dootson8-May-09 4:47 

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.