purpose
I am writing a small library for which portability is important. It was designed to assume only a mostly compatible C90 environment (ISO / IEC 9899: 1990) ... nothing more. The set of functions provided by the library works (read / write) in the internal data structure. I looked at some other design alternatives, but nothing else is possible for the library trying to achieve .
Question
Are there any portable algorithms, methods, or spells that can be used to ensure thread safety? I am not interested in performing functions repeatedly. Moreover, I'm not interested in speed or (possibly) depletion of resources if the algorithm / technique / spell is portable. Ideally, I don't want to depend on any libraries (such as GNU Pth) or system operations (such as atomic tests and settings).
I considered a modification of the Lamport bakery algorithm , but I do not know how to change it to work inside functions called threads instead of working in the threads themselves.
Any help is greatly appreciated.
anon
source
share