-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reentrancy and thread-safety #346
Comments
dschlaep
added a commit
that referenced
this issue
Aug 4, 2023
Development for v7.1.0 * Simulation output remains the same as the previous version. * Prepare for SOILWAT2 to become thread-safe and reentrant (#346; @N1ckP3rsl3y) * Definition clarifications * Thread-safe - Multiple threads (a future SOILWAT2 development) will not influence each other unintentionally. Here, we implemented structures to enable thread-local storage, i.e., each thread operates on local data structures or with static data. * Reentrant - The ability to correctly execute any part of the program by multiple threads simultaneously but independently from others. * All non-static variables are replaced by local variables; functions gained arguments to pass local variables by reference (replacing global variables). * New main abstract types * SW_ALL - Contains the existing structures that are relevant for the simulation itself, e.g., SW_MODEL, SW_SOILWAT, SW_WEATHER. * PATH_INFO - Holds information about location of input and output data, e.g., directories, file paths to input data. * SW_OUTPUT_POINTERS - Points to requested output subroutines. * LOG_INFO - Manages information for logging warnings and errors. * Tests now require `c++14` and utilize `googletest` `v1.14.0` (issue #339). * Bugfixes * Fix an error where a pointer was freed even though it was not allocated (issue #356; @dschlaep). * Fix memory leak in test of `SW_VPD_construct()` (issue #205; @dschlaep). Changes to inputs * The output separator `OUTSEP` has been unused since the switch (`v4.0.0`) from writing free-form text files to `"csv"` spreadsheets (where the separator is fixed to a comma); the occurrence of `OUTSEP` in `"outsetup.in"` is now deprecated and triggers a warning.
dschlaep
added a commit
that referenced
this issue
Oct 24, 2023
Release/devel v7.2.0 * SOILWAT2 now handles errors more gracefully (#346; @N1ckP3rsl3y, @dschlaep). * Code no longer crashes on error immediately (except for STEPWAT2). * Code stores messages of warnings and error status. * All functions now check for errors and return early (after cleaning up memory). * SOILWAT2 now defines its own structure for random numbers (#373; @dschlaep). This allows to hide implementation details, i.e., STEPWAT2 will no longer need to interact directly with `pcg` and rSOILWAT2 will no longer depend on `pcg` which it never has used. * New `sw_strtok()` is thread-safe and replaces not thread-safe `strtok()` (#376; @N1ckP3rsl3y). * Obsolete code in DEBUG_MEM* sections is removed (#369; @dschlaep).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Convert SOILWAT2 to be reentrant and thread-safe
For instance:
global variables, e.g.,
SW_Weather
,SW_Site
main()
(SW_Main.c, sw_maintest.cc, etc.)functions that return a pointer to static data, e.g.,
DirName()
str_toupper()
example in programming-writing-reentrant-threadsafe-codemodule-level local variables
MyFilename
main()
(see section "global variables"), e.g.,memoized_G_o
"static const" variables should not be a problem per se
"static" functions should not be a problem per se
this is not an exhaustive list
The text was updated successfully, but these errors were encountered: