Skip to content

Commit

Permalink
sys/posix/pthread/pthread.c: pthread_create fix
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JulianHolzwarth committed Sep 6, 2019
1 parent d6356bd commit d76bb68
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sys/posix/pthread/pthread.c
Expand Up @@ -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++){
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d76bb68

Please sign in to comment.