Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MSDN volatile sample Pin
peterchen28-Dec-07 4:32
peterchen28-Dec-07 4:32 
GeneralRe: MSDN volatile sample Pin
Maxwell Chen28-Dec-07 4:34
Maxwell Chen28-Dec-07 4:34 
GeneralRe: MSDN volatile sample Pin
George_George28-Dec-07 18:37
George_George28-Dec-07 18:37 
GeneralRe: MSDN volatile sample Pin
peterchen29-Dec-07 10:51
peterchen29-Dec-07 10:51 
GeneralRe: MSDN volatile sample Pin
George_George29-Dec-07 19:51
George_George29-Dec-07 19:51 
GeneralRe: MSDN volatile sample Pin
peterchen30-Dec-07 0:22
peterchen30-Dec-07 0:22 
GeneralRe: MSDN volatile sample Pin
George_George30-Dec-07 0:39
George_George30-Dec-07 0:39 
GeneralRe: MSDN volatile sample Pin
peterchen30-Dec-07 2:19
peterchen30-Dec-07 2:19 
1.) The compiler doesn#t rea the MSDN Smile | :)

All it knows is that it is imported from an Kernel32.dll with a given signature. The funciton could do anything. You could have designed it to e.g. poll for a file, and when it's gone it throws. (And that's exactly what MUST happen if the DLL is replaced with one that does this.)

(Point of above post: even if the compiler had special built-in knowledge about Sleep(), it couldn't help you in all the cases where ).

2.) Maybe I wasn't clear with this.
Of course, volatile doesn't affect atomicity.

A memory read/write is atomic if it byte, word, DWORD (or QWORD on 64 bit) and is aligned on an address a multiple of its size. Then, the value is read or written in a single cycle, and no other thread or core could possibly interrupt.

However, all caching problems still remain: either caching in a register (by the optimizer), or caching in the CPU. volatile helps with these (but would be mostly useless with non-atomic accesses anyway).

We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
My first real C# project | Linkify!| FoldWithUs! | sighist


GeneralRe: MSDN volatile sample Pin
George_George30-Dec-07 2:48
George_George30-Dec-07 2:48 
GeneralRe: MSDN volatile sample Pin
peterchen30-Dec-07 3:47
peterchen30-Dec-07 3:47 
GeneralRe: MSDN volatile sample Pin
George_George31-Dec-07 3:48
George_George31-Dec-07 3:48 
QuestionI define a template function in header, code in cpp. Include header. Undefined reference?? Pin
ArmchairAthlete27-Dec-07 21:47
ArmchairAthlete27-Dec-07 21:47 
AnswerRe: I define a template function in header, code in cpp. Include header. Undefined reference?? Pin
ArmchairAthlete27-Dec-07 21:48
ArmchairAthlete27-Dec-07 21:48 
GeneralRe: I define a template function in header, code in cpp. Include header. Undefined reference?? Pin
CPallini28-Dec-07 1:03
mveCPallini28-Dec-07 1:03 
QuestionRe: I define a template function in header, code in cpp. Include header. Undefined reference?? Pin
David Crow28-Dec-07 2:40
David Crow28-Dec-07 2:40 
QuestionI want to write C program about CPU Scheduling simmulator Pin
Smith1927-Dec-07 21:40
Smith1927-Dec-07 21:40 
GeneralRe: I want to write C program about CPU Scheduling simmulator Pin
Garth J Lancaster27-Dec-07 23:32
professionalGarth J Lancaster27-Dec-07 23:32 
GeneralTrayIcon RightClick - Enable and Disable Pin
Paulraj G27-Dec-07 18:24
Paulraj G27-Dec-07 18:24 
GeneralRe: TrayIcon RightClick - Enable and Disable Pin
Nishad S27-Dec-07 19:52
Nishad S27-Dec-07 19:52 
GeneralProblem in writing template function inside class Pin
Naveen27-Dec-07 18:21
Naveen27-Dec-07 18:21 
GeneralRe: Problem in writing template function inside class [modified] Pin
Maxwell Chen27-Dec-07 18:47
Maxwell Chen27-Dec-07 18:47 
GeneralRe: Problem in writing template function inside class Pin
Naveen27-Dec-07 19:16
Naveen27-Dec-07 19:16 
GeneralRe: Problem in writing template function inside class Pin
Sarath C27-Dec-07 20:11
Sarath C27-Dec-07 20:11 
GeneralRe: Problem in writing template function inside class Pin
Maxwell Chen27-Dec-07 22:34
Maxwell Chen27-Dec-07 22:34 
GeneralRe: Problem in writing template function inside class Pin
Mahesh Kulkarni27-Dec-07 22:29
Mahesh Kulkarni27-Dec-07 22:29 

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.