Skip to content

Commit

Permalink
Use 'pthread_equal()' to compare thread id.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed May 20, 2024
1 parent 2082c17 commit c2eb095
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/kernel/thrdpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include "msgqueue.h"
#include "thrdpool.h"

Expand Down Expand Up @@ -78,7 +77,7 @@ static void *__thrdpool_routine(void *arg)
pthread_cond_signal(pool->terminate);

pthread_mutex_unlock(&pool->mutex);
if (memcmp(&tid, &__zero_tid, sizeof (pthread_t)) != 0)
if (!pthread_equal(tid, __zero_tid))
pthread_join(tid, NULL);

return NULL;
Expand All @@ -103,7 +102,7 @@ static void __thrdpool_terminate(int in_pool, thrdpool_t *pool)
pthread_cond_wait(&term, &pool->mutex);

pthread_mutex_unlock(&pool->mutex);
if (memcmp(&pool->tid, &__zero_tid, sizeof (pthread_t)) != 0)
if (!pthread_equal(pool->tid, __zero_tid))
pthread_join(pool->tid, NULL);
}

Expand Down Expand Up @@ -159,7 +158,7 @@ thrdpool_t *thrdpool_create(size_t nthreads, size_t stacksize)
{
pool->stacksize = stacksize;
pool->nthreads = 0;
memset(&pool->tid, 0, sizeof (pthread_t));
pool->tid = __zero_tid;
pool->terminate = NULL;
if (__thrdpool_create_threads(nthreads, pool) >= 0)
return pool;
Expand Down

0 comments on commit c2eb095

Please sign in to comment.