-
Notifications
You must be signed in to change notification settings - Fork 12
Thread Safety
This repository includes modifications to Softfloat 3a to support concurrent use of the library by multiple concurrent threads. This is required to support Hercules, which allows multiple emulated CPUs. Hercules allocates a separate host system thread to each emulated CPU. Hercules manages thread safety for the data structures that support CPU threads, but libraries that maintain a global state outside of Hercules must be thread safe.
Softfloat 3a is not, unmodified, thread safe. It has three global state variables that are used to communicate with calling routines, and modification for IBM Binary Floating Point adds a fourth variable, a structure. One of the global variables, softfloat_detectTininess, does not vary during Hercules use, so is in effect a constant and need not be a thread safe variable.
The modifications to Softfloat 3a use compiler/runtime capabilities to provide thread safety. Preprocessor code in softfloat.h detects the compiler environment in use and uses declaration modifiers appropriate to that environment for the two variables and one structure. The result of that code is used in softfloat.h to declare the variables and structure as thread-safe. The result is also used in softfloat.c to define the variables and structure as thread-safe.
This Wiki Copyright © 2016 by Stephen R. Orso. This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.