summaryrefslogtreecommitdiffstats
path: root/src/H5TS.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-02-07 21:14:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-02-07 21:14:19 (GMT)
commit168d67dbd20923feef30fb76c6b569ef2e5add4a (patch)
tree2bcfd51c39665400804e92ac0fb13d42b2df96c3 /src/H5TS.c
parent4e8da9d2246a0bba1afb5c678346b2f1c4633c69 (diff)
downloadhdf5-168d67dbd20923feef30fb76c6b569ef2e5add4a.zip
hdf5-168d67dbd20923feef30fb76c6b569ef2e5add4a.tar.gz
hdf5-168d67dbd20923feef30fb76c6b569ef2e5add4a.tar.bz2
[svn-r6383] Purpose:
New feature for developers. Description: Added "function stack" tracing to library. This allows developers (there is no public API) to call H5FS_print within the library and get a listing of the functions traversed to reach that point in the library. Eventually, I may add support for reporting the parameters to each function also... Mainly for debugging parallel I/O programs, but I think it will come in handy in other cases also. The function stack tracking is controlled with a configure switch: --enable-funcstack, which defaults to enabled currently. When we branch for 1.6, we should change the default setting on the branch to be disabled. Also, added a destructor to the thread-specific keys when thread-safety is turned on in the library. Otherwise, they were leaking memory and causing difficult to debug errors in threaded programs (like the test/ttsafe test). Platforms tested: Tested h5committest {arabica (fortran), eirene (fortran, C++) modi4 (parallel, fortran)} FreeBSD 4.7 (sleipnir) w/thread-safety enabled. Misc. update: Updated MANIFEST with new files added (src/H5FS.c & src/H5FDprivate.h) Update release_docs/RELEASE with thread-safety bug fix.
Diffstat (limited to 'src/H5TS.c')
-rw-r--r--src/H5TS.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/src/H5TS.c b/src/H5TS.c
index ce3d5ef..c577ebc 100644
--- a/src/H5TS.c
+++ b/src/H5TS.c
@@ -30,6 +30,7 @@ typedef struct H5TS_cancel_struct {
/* Global variable definitions */
pthread_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT;
pthread_key_t H5TS_errstk_key_g;
+pthread_key_t H5TS_funcstk_key_g;
pthread_key_t H5TS_cancel_key_g;
hbool_t H5TS_allow_concurrent_g = FALSE; /* concurrent APIs override this */
@@ -38,6 +39,36 @@ hbool_t H5TS_allow_concurrent_g = FALSE; /* concurrent APIs override this */
static void H5TS_mutex_init(H5TS_mutex_t *mutex);
#endif /* NOT_USED */
+
+/*--------------------------------------------------------------------------
+ * NAME
+ * H5TS_key_destructor
+ *
+ * USAGE
+ * H5TS_key_destructor()
+ *
+ * RETURNS
+ *
+ * DESCRIPTION
+ * Frees the memory for a key. Called by each thread as it exits.
+ * Currently all the thread-specific information for all keys are simple
+ * structures allocated with malloc, so we can free them all uniformly.
+ *
+ * PROGRAMMER: Quincey Koziol
+ * February 7, 2003
+ *
+ * MODIFICATIONS:
+ *
+ *--------------------------------------------------------------------------
+ */
+static void
+H5TS_key_destructor(void *key_val)
+{
+ /* Use HDfree here instead of H5MM_xfree(), to avoid calling the H5FS routines */
+ if(key_val!=NULL)
+ HDfree(key_val);
+}
+
/*--------------------------------------------------------------------------
* NAME
* H5TS_first_thread_init
@@ -73,46 +104,14 @@ H5TS_first_thread_init(void)
H5_g.init_lock.lock_count = 0;
/* initialize key for thread-specific error stacks */
- pthread_key_create(&H5TS_errstk_key_g, NULL);
+ pthread_key_create(&H5TS_errstk_key_g, H5TS_key_destructor);
- /* initialize key for thread cancellability mechanism */
- pthread_key_create(&H5TS_cancel_key_g, NULL);
-}
+ /* initialize key for thread-specific function stacks */
+ pthread_key_create(&H5TS_funcstk_key_g, H5TS_key_destructor);
-#ifdef NOT_USED
-/*--------------------------------------------------------------------------
- * NAME
- * H5TS_mutex_init
- *
- * USAGE
- * H5TS_mutex_init(&mutex_var)
- *
- * RETURNS
- *
- * DESCRIPTION
- * Recursive lock semantics for HDF5 (lock initialization) -
- * Multiple acquisition of a lock by a thread is permitted with a
- * corresponding unlock operation required.
- *
- * PROGRAMMER: Chee Wai LEE
- * May 2, 2000
- *
- * MODIFICATIONS:
- *
- * 19 May 2000, Bill Wendling
- * Changed (*foo). form of accessing structure members to the -> form.
- *
- *--------------------------------------------------------------------------
- */
-static void
-H5TS_mutex_init(H5TS_mutex_t *mutex)
-{
- H5_g.init_lock.owner_thread = NULL;
- pthread_mutex_init(&mutex->atomic_lock, NULL);
- pthread_cond_init(&mutex->cond_var, NULL);
- mutex->lock_count = 0;
+ /* initialize key for thread cancellability mechanism */
+ pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor);
}
-#endif /* NOT_USED */
/*--------------------------------------------------------------------------
* NAME