Click here to Skip to main content
15,887,328 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Application crash when application launch. Pin
David Crow13-May-09 3:13
David Crow13-May-09 3:13 
GeneralRe: Application crash when application launch. Pin
Cedric Moonen13-May-09 3:22
Cedric Moonen13-May-09 3:22 
GeneralRe: Application crash when application launch. Pin
Le@rner13-May-09 18:28
Le@rner13-May-09 18:28 
GeneralRe: Application crash when application launch. Pin
Cedric Moonen13-May-09 20:17
Cedric Moonen13-May-09 20:17 
GeneralRe: Application crash when application launch. Pin
Le@rner17-May-09 20:12
Le@rner17-May-09 20:12 
GeneralRe: Application crash when application launch. Pin
Le@rner17-May-09 20:22
Le@rner17-May-09 20:22 
QuestionAtomic operations involving __int64 on 32 bit machines Pin
Eikthrynir13-May-09 2:14
Eikthrynir13-May-09 2:14 
AnswerRe: Atomic operations involving __int64 on 32 bit machines [modified] Pin
Randor 13-May-09 4:47
professional Randor 13-May-09 4:47 
Eikthrynir wrote:
Question 1: Is this scenario valid? Can it happen on a 32 bit machine?


Yes as the MSDN states in the article Interlocked Variable Access[^]:
Reads and writes to 64-bit values are not guaranteed to be atomic on 32-bit Windows. Reads and writes to variables of other sizes are not guaranteed to be atomic on any platform.

Eikthrynir wrote:
Question 2: What if 32 bits get written to EAX, ThreadB resumes and writes to m_i64Value and after that, ThreadC resumes and the other 32 bits (changed by ThreadB) go to EDX? Is this also a possibility on 32 bit machines? If yes, what is the best way to return such a value (__int64, in this example)?


Eikthrynir wrote:
Question 3: But what if we still want to actually return the value and not copy it to the memory pointed by a_pi64Value? Can this be done somehow thread-safely and using the return instruction?


I would personally do it like this:

//Add zero to the value and return the initial value.
LONGLONG GetValue(__int64 *a_pi64Value)
{
	return InterlockedExchangeAdd64(a_pi64Value,0);
}


Best Wishes,
-David Delaune

modified on Wednesday, May 13, 2009 11:41 AM

GeneralRe: Atomic operations involving __int64 on 32 bit machines Pin
Eikthrynir14-May-09 0:17
Eikthrynir14-May-09 0:17 
GeneralRe: Atomic operations involving __int64 on 32 bit machines Pin
Randor 14-May-09 6:59
professional Randor 14-May-09 6:59 
QuestionS.M.A.R.T support in SCSI hard disk drive Pin
Abinash Mohanty13-May-09 1:27
Abinash Mohanty13-May-09 1:27 
QuestionRe: S.M.A.R.T support in SCSI hard disk drive Pin
Rajesh R Subramanian13-May-09 1:50
professionalRajesh R Subramanian13-May-09 1:50 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
Abinash Mohanty13-May-09 2:31
Abinash Mohanty13-May-09 2:31 
AnswerRe: S.M.A.R.T support in SCSI hard disk drive Pin
David Crow13-May-09 3:14
David Crow13-May-09 3:14 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
Rajesh R Subramanian13-May-09 3:32
professionalRajesh R Subramanian13-May-09 3:32 
QuestionRe: S.M.A.R.T support in SCSI hard disk drive Pin
David Crow13-May-09 3:42
David Crow13-May-09 3:42 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
Abinash Mohanty13-May-09 18:12
Abinash Mohanty13-May-09 18:12 
NewsRe: S.M.A.R.T support in SCSI hard disk drive Pin
ipforce14-May-09 1:41
ipforce14-May-09 1:41 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
David Crow14-May-09 2:33
David Crow14-May-09 2:33 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
ipforce14-May-09 4:10
ipforce14-May-09 4:10 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
aishui090515-Sep-09 17:13
aishui090515-Sep-09 17:13 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
ipforce15-Sep-09 21:12
ipforce15-Sep-09 21:12 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
aishui090518-Sep-09 19:12
aishui090518-Sep-09 19:12 
GeneralRe: S.M.A.R.T support in SCSI hard disk drive Pin
ipforce18-Sep-09 20:48
ipforce18-Sep-09 20:48 
Questionhelp me Create ISO image file from folders... Pin
lek25813-May-09 0:37
lek25813-May-09 0:37 

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.