sys/posix/pthread/pthread.c: pthread_create fix
The function insert returns KERNEL_PID_UNDEF now because pthread_create checks for it. In pthread_create it checks now if thread_create returns a valid pid
This commit is contained in:
parent
d6356bdc08
commit
d76bb689d6
@ -87,7 +87,7 @@ static void *pthread_start_routine(void *pt_)
|
|||||||
|
|
||||||
static int insert(pthread_thread_t *pt)
|
static int insert(pthread_thread_t *pt)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int result = KERNEL_PID_UNDEF;
|
||||||
mutex_lock(&pthread_mutex);
|
mutex_lock(&pthread_mutex);
|
||||||
|
|
||||||
for (int i = 0; i < MAXTHREADS; i++){
|
for (int i = 0; i < MAXTHREADS; i++){
|
||||||
@ -160,7 +160,7 @@ int pthread_create(pthread_t *newthread, const pthread_attr_t *attr, void *(*sta
|
|||||||
pthread_start_routine,
|
pthread_start_routine,
|
||||||
pt,
|
pt,
|
||||||
"pthread");
|
"pthread");
|
||||||
if (pt->thread_pid == KERNEL_PID_UNDEF) {
|
if (!pid_is_valid(pt->thread_pid)) {
|
||||||
free(pt->stack);
|
free(pt->stack);
|
||||||
free(pt);
|
free(pt);
|
||||||
pthread_sched_threads[pthread_pid-1] = NULL;
|
pthread_sched_threads[pthread_pid-1] = NULL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user