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

C / C++ / MFC

 
Generalsynchronizing simple types Pin
Konrad Windszus1-Mar-04 2:48
Konrad Windszus1-Mar-04 2:48 
GeneralRe: synchronizing simple types Pin
Prakash Nadar1-Mar-04 3:04
Prakash Nadar1-Mar-04 3:04 
GeneralRe: synchronizing simple types Pin
Konrad Windszus1-Mar-04 4:08
Konrad Windszus1-Mar-04 4:08 
GeneralRe: synchronizing simple types Pin
Prakash Nadar1-Mar-04 4:43
Prakash Nadar1-Mar-04 4:43 
GeneralRe: synchronizing simple types Pin
Joe Woodbury1-Mar-04 18:35
professionalJoe Woodbury1-Mar-04 18:35 
GeneralRe: synchronizing simple types Pin
Konrad Windszus2-Mar-04 0:20
Konrad Windszus2-Mar-04 0:20 
GeneralRe: synchronizing simple types Pin
Robert A. T. Káldy2-Mar-04 1:04
Robert A. T. Káldy2-Mar-04 1:04 
GeneralRe: synchronizing simple types Pin
Konrad Windszus2-Mar-04 2:14
Konrad Windszus2-Mar-04 2:14 
Thanks for your answer, but in the MSDN Library I found the following sentence:

Simple reads and writes to properly-aligned 32-bit variables are atomic.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/interlocked_variable_access.asp

What about other variables like char (8bit)? Isn't it possible, that during the read process another thread writes to the variable with InterlockedExchange. After this the read thread is reading the second part of the variable. It gets corrupted, because it wasn't an atomic read. What about other variables like 8, 16 bit. Are reads always atomic?

And do I need volatile for these variables if I write to them only via InterlockedExchange.

Thanks for any answer
Konrad
GeneralRe: synchronizing simple types Pin
Joe Woodbury2-Mar-04 5:31
professionalJoe Woodbury2-Mar-04 5:31 
GeneralRe: synchronizing simple types Pin
Robert A. T. Káldy2-Mar-04 5:33
Robert A. T. Káldy2-Mar-04 5:33 
GeneralQuery: Display Line Number infront of each Line of source (MFC) Pin
irshad_bukhari1-Mar-04 2:46
irshad_bukhari1-Mar-04 2:46 
GeneralRe: Query: Display Line Number infront of each Line of source (MFC) Pin
Prakash Nadar1-Mar-04 2:57
Prakash Nadar1-Mar-04 2:57 
GeneralRe: Query: Display Line Number infront of each Line of source (MFC) Pin
David Crow1-Mar-04 3:01
David Crow1-Mar-04 3:01 
GeneralRe: Query: Display Line Number infront of each Line of source (MFC) Pin
irshad_bukhari1-Mar-04 21:53
irshad_bukhari1-Mar-04 21:53 
Generaldebug a service Pin
Anonymous1-Mar-04 2:41
Anonymous1-Mar-04 2:41 
GeneralRe: debug a service Pin
Prakash Nadar1-Mar-04 2:56
Prakash Nadar1-Mar-04 2:56 
GeneralRe: debug a service Pin
Diddy2-Mar-04 11:30
Diddy2-Mar-04 11:30 
GeneralWindows shutdown Pin
rw1041-Mar-04 2:22
rw1041-Mar-04 2:22 
GeneralRe: Windows shutdown Pin
David Crow1-Mar-04 3:09
David Crow1-Mar-04 3:09 
GeneralRe: Windows shutdown Pin
KaЯl1-Mar-04 3:11
KaЯl1-Mar-04 3:11 
GeneralMenu... Pin
Micke B29-Feb-04 23:54
Micke B29-Feb-04 23:54 
GeneralRe: Menu... Pin
Prakash Nadar1-Mar-04 0:09
Prakash Nadar1-Mar-04 0:09 
GeneralRe: Menu... Pin
Steve S1-Mar-04 0:22
Steve S1-Mar-04 0:22 
GeneralRe: Menu... Pin
Anonymous1-Mar-04 3:04
Anonymous1-Mar-04 3:04 
GeneralRe: Menu... Pin
Micke B1-Mar-04 3:24
Micke B1-Mar-04 3:24 

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.