From: Matt Birkholz Date: Sat, 6 Dec 2014 07:01:16 +0000 (-0700) Subject: smp: share: pruxdld.o X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=3e878216432186a8277ef44005f16fd19b8333dd;p=mit-scheme.git smp: share: pruxdld.o --- diff --git a/README.txt b/README.txt index 34f4e0ca9..e0eedc05b 100644 --- a/README.txt +++ b/README.txt @@ -886,6 +886,10 @@ command line. The remaining 12 belong to the 7 microcode modules and 00000004 b loaded_handles_size 00000008 b n_loaded_handles + OK. Now serialized, except the reload_cleanup, which + presumably is done during a gc-wait (during Prim_band_load), + and during OS_reset (which is called where?). + pruxffi.o: 00000004 b c_call_continue 00000000 B cstack_depth diff --git a/src/microcode/pruxdld.c b/src/microcode/pruxdld.c index ca92f1522..38cde21f9 100644 --- a/src/microcode/pruxdld.c +++ b/src/microcode/pruxdld.c @@ -26,7 +26,6 @@ USA. /* This file contains the interface to the unix dynamic loader. */ -#include "scheme.h" #include "prims.h" #include "usrdef.h" #include "syscall.h" @@ -45,6 +44,13 @@ static void dld_unload_all (void); static void * dld_lookup (void *, const char *); #define ARG_HANDLE(n) ((void *) (arg_ulong_integer (n))) + +#ifdef ENABLE_SMP +static pthread_mutex_t mutex = MUTEX_INITIALIZER; +# ifdef ENABLE_DEBUGGING_TOOLS +static bool locked_p = false; +# endif +#endif DEFINE_PRIMITIVE ("DLD-LOAD-FILE", Prim_dld_load_file, 2, 2, "(FILENAME WEAK-PAIR)\n\ @@ -111,6 +117,7 @@ dld_load (const char * path) { void * handle; + LOCK(); if (!cleanup_registered_p) { add_reload_cleanup (dld_unload_all); @@ -143,6 +150,7 @@ dld_load (const char * path) } } (loaded_handles[n_loaded_handles++]) = handle; + UNLOCK(); return (handle); } @@ -160,9 +168,11 @@ dld_finalize (void * handle) static void dld_unload (void * handle) { + LOCK(); dld_finalize (handle); if ((dlclose (handle)) != 0) { + UNLOCK(); SCHEME_OBJECT v = (allocate_marked_vector (TC_VECTOR, 3, 1)); VECTOR_SET (v, 0, (LONG_TO_UNSIGNED_FIXNUM (ERR_IN_SYSTEM_CALL))); VECTOR_SET (v, 1, (char_pointer_to_string ("dlclose"))); @@ -180,6 +190,7 @@ dld_unload (void * handle) break; } } + UNLOCK(); } static void @@ -209,9 +220,11 @@ dld_lookup (void * handle, const char * symbol) void * address; const char * error_string; + LOCK(); dlerror (); /* discard any outstanding errors */ address = (dlsym (handle, symbol)); error_string = (dlerror ()); + UNLOCK(); if (error_string != 0) { SCHEME_OBJECT v = (allocate_marked_vector (TC_VECTOR, 3, 1));