update samgr/adapter/posix/thread_adapter.c.
This commit is contained in:
parent
de9905cd40
commit
9d13ef34e3
|
@ -21,7 +21,8 @@
|
|||
#define MIN_STACK_SIZE 0x8000
|
||||
static int g_threadCount = 0;
|
||||
static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_key_t g_localKey = 0;
|
||||
static pthread_key_t g_localKey = -1;
|
||||
static pthread_once_t g_localKeyOnce = PTHREAD_ONCE_INIT;
|
||||
|
||||
MutexId MUTEX_InitValue()
|
||||
{
|
||||
|
@ -59,6 +60,11 @@ void MUTEX_GlobalUnlock(void)
|
|||
pthread_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
static void KeyCreate()
|
||||
{
|
||||
(void) pthread_key_create(&g_localKey, NULL);
|
||||
}
|
||||
|
||||
ThreadId THREAD_Create(Runnable run, void *argv, const ThreadAttr *attr)
|
||||
{
|
||||
pthread_attr_t threadAttr;
|
||||
|
@ -72,7 +78,7 @@ ThreadId THREAD_Create(Runnable run, void *argv, const ThreadAttr *attr)
|
|||
#endif
|
||||
pthread_attr_setschedpolicy(&threadAttr, SCHED_RR);
|
||||
pthread_attr_setschedparam(&threadAttr, &sched);
|
||||
pthread_key_create(&g_localKey, NULL);
|
||||
(void) pthread_once(&g_localKeyOnce, KeyCreate);
|
||||
pthread_t threadId = 0;
|
||||
int errno = pthread_create(&threadId, &threadAttr, run, argv);
|
||||
if (errno != 0) {
|
||||
|
|
Loading…
Reference in New Issue