When running the stress test of pthread create/destroy, a crash may
oocur in __get_tls(). That is caused by the race condition with __set_tls( ):
Author: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
0
};
+static pthread_mutex_t _tls_desc_lock = PTHREAD_MUTEX_INITIALIZER;
+
struct _thread_area_head {
void *self;
};
{
int rc, segment;
+ pthread_mutex_lock(&_tls_desc_lock);
_tls_desc.base_addr = (unsigned long)ptr;
/* We also need to write the location of the tls to ptr[0] */
asm __volatile__ (
" movw %w0, %%gs" :: "q"(segment)
);
+ pthread_mutex_unlock(&_tls_desc_lock);
+
return 0;
}