123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "pthread.h"
- #include "implement.h"
- pthread_t
- pte_new (void)
- {
- pthread_t t;
- pthread_t nil = {NULL, 0};
- pte_thread_t * tp;
-
- t = pte_threadReusePop ();
- if (NULL != t.p)
- {
- tp = (pte_thread_t *) t.p;
- }
- else
- {
-
- tp = (pte_thread_t *) calloc (1, sizeof(pte_thread_t));
- if (tp == NULL)
- {
- return nil;
- }
-
- t.p = tp->ptHandle.p = tp;
- t.x = tp->ptHandle.x = 0;
- }
-
- tp->sched_priority = pte_osThreadGetMinPriority();
- tp->detachState = PTHREAD_CREATE_JOINABLE;
- tp->cancelState = PTHREAD_CANCEL_ENABLE;
- tp->cancelType = PTHREAD_CANCEL_DEFERRED;
- tp->cancelLock = PTHREAD_MUTEX_INITIALIZER;
- tp->threadLock = PTHREAD_MUTEX_INITIALIZER;
- return t;
- }
|