[cig-commits] [commit] master: make the threading a bit more robust: if c_wait... is called before the thread is spawned, (b2c8f92)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Fri Sep 5 07:51:27 PDT 2014


Repository : https://github.com/geodynamics/axisem

On branch  : master
Link       : https://github.com/geodynamics/axisem/compare/7718f39ed544fb7670cf60f350d80b9b089a422f...b2c8f921d7cb70dd1d0edb25c35f6bd6de572cc7

>---------------------------------------------------------------

commit b2c8f921d7cb70dd1d0edb25c35f6bd6de572cc7
Author: martinvandriel <martin at vandriel.de>
Date:   Fri Sep 5 16:50:29 2014 +0200

    make the threading a bit more robust: if c_wait... is called before the thread is spawned,
    
    on some machines resulted in a segfault. Now this should be safe


>---------------------------------------------------------------

b2c8f921d7cb70dd1d0edb25c35f6bd6de572cc7
 SOLVER/pthread.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/SOLVER/pthread.c b/SOLVER/pthread.c
index cbac767..3f4f622 100644
--- a/SOLVER/pthread.c
+++ b/SOLVER/pthread.c
@@ -26,7 +26,7 @@
 // compare https://computing.llnl.gov/tutorials/pthreads/
 
 // careful with global variable, this only works if the calling programm is not threaded!
-pthread_t thread;
+pthread_t thread = (pthread_t) 0;
 
 // stub - so c knows what the function looks like
 extern void __nc_routines_MOD_nc_dump_strain_to_disk();
@@ -51,7 +51,8 @@ void c_spawn_dumpthread(int* val){
 // wait for the IO thread to finish, to be called from fortran
 // global thead variable allows to come back to the thread
 void c_wait_for_io() {
-   void *status;
-   pthread_join(thread, &status);
+   if (thread != (pthread_t) 0){
+       pthread_join(thread, NULL);
+   }   
 }
 



More information about the CIG-COMMITS mailing list