Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Jul : What is thread-safe in the Windows API?

www.cryer.info
Managed Newsgroup Archive

What is thread-safe in the Windows API?

Subject:What is thread-safe in the Windows API?
Posted by:"Enquiring Mind" (enquiring.mind@nospam.btopenworld.com)
Date:Wed, 2 Jul 2008 15:35:57

Hi,

When Farshad pointed out that the ReadFile and WriteFile API functions are
not thread-safe,  I asked myself whether *any* API functions are
thread-safe. I also wondered what operations and data types can be
considered atomic and therefore thread-safe. Is a simple operation like
calling TEvent.ResetEvent thread-safe because it involves setting the value
of an unsigned integer or a  Boolean? Is the function GetLastError
thread-safe, because it only reads an atomic data type?  Is an assignment to
a double-precision variable thread-safe? Are all Get and Put operations on
pointers thread-safe because the data type is a 4-byte cardinal? Is calling
a property that internally sets an integer not thread-safe because a method
call might not be thread-safe?

TiA for any guidance,

EM

Replies:

www.cryer.info
Managed Newsgroup Archive