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:
JulianHolzwarth 2019-08-21 16:13:28 +02:00
parent d6356bdc08
commit d76bb689d6

View File

@ -87,7 +87,7 @@ static void *pthread_start_routine(void *pt_)
static int insert(pthread_thread_t *pt)
{
int result = -1;
int result = KERNEL_PID_UNDEF;
mutex_lock(&pthread_mutex);
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,
pt,
"pthread");
if (pt->thread_pid == KERNEL_PID_UNDEF) {
if (!pid_is_valid(pt->thread_pid)) {
free(pt->stack);
free(pt);
pthread_sched_threads[pthread_pid-1] = NULL;