Implement pthread_cond_broadcast wrapper for lib-pthread (#982)

Implement pthread_cond_broadcast wrapper for lib-pthread
- support pthread_cond_broadcast wrapper for posix/linux-sgx/windows
- update document for building multi-thread wasm app with emcc
This commit is contained in:
Xu Jun
2022-01-25 09:28:02 +08:00
committed by GitHub
parent 5631a2aa18
commit 90a0057d33
7 changed files with 125 additions and 21 deletions

View File

@ -262,6 +262,17 @@ os_cond_signal(korp_cond *cond)
return BHT_OK;
}
int
os_cond_broadcast(korp_cond *cond)
{
assert(cond);
if (pthread_cond_broadcast(cond) != BHT_OK)
return BHT_ERROR;
return BHT_OK;
}
int
os_thread_join(korp_tid thread, void **value_ptr)
{

View File

@ -179,6 +179,16 @@ os_cond_reltimedwait(korp_cond *cond, korp_mutex *mutex, uint64 useconds);
int
os_cond_signal(korp_cond *cond);
/**
* Broadcast the condition variable
*
* @param cond condition variable
*
* @return 0 if success
*/
int
os_cond_broadcast(korp_cond *cond);
/****************************************************
* Section 2 *
* Socket support *

View File

@ -164,6 +164,19 @@ os_cond_signal(korp_cond *cond)
return BHT_OK;
}
int
os_cond_broadcast(korp_cond *cond)
{
#ifndef SGX_DISABLE_PTHREAD
assert(cond);
if (pthread_cond_broadcast(cond) != BHT_OK)
return BHT_ERROR;
#endif
return BHT_OK;
}
int
os_thread_join(korp_tid thread, void **value_ptr)
{

View File

@ -567,6 +567,24 @@ os_cond_signal(korp_cond *cond)
return BHT_OK;
}
int
os_cond_broadcast(korp_cond *cond)
{
/* Signal all of the wait node of wait list */
os_mutex_lock(&cond->wait_list_lock);
if (cond->thread_wait_list) {
os_thread_wait_node *p = cond->thread_wait_list;
while (p) {
os_sem_signal(&p->sem);
p = p->next;
}
}
os_mutex_unlock(&cond->wait_list_lock);
return BHT_OK;
}
static os_thread_local_attribute uint8 *thread_stack_boundary = NULL;
static ULONG