LibC: Rewrite pthread_mutex using a futex

This commit is contained in:
2025-08-21 01:49:55 +03:00
parent 1d6c08478d
commit fb61cab70d
3 changed files with 72 additions and 71 deletions

View File

@@ -26,7 +26,8 @@ typedef struct
typedef struct
{
pthread_mutexattr_t attr;
pthread_t locker;
uint32_t futex;
uint32_t waiters;
unsigned lock_depth;
} pthread_mutex_t;

View File

@@ -79,7 +79,7 @@ struct uthread
#define PTHREAD_SPIN_INITIALIZER (pthread_spinlock_t)0
#define PTHREAD_COND_INITIALIZER (pthread_cond_t){ { CLOCK_REALTIME, 0 }, PTHREAD_SPIN_INITIALIZER, NULL }
#define PTHREAD_MUTEX_INITIALIZER (pthread_mutex_t){ { PTHREAD_MUTEX_DEFAULT, 0 }, 0, 0 }
#define PTHREAD_MUTEX_INITIALIZER (pthread_mutex_t){ { PTHREAD_MUTEX_DEFAULT, 0 }, 0, 0, 0 }
#define PTHREAD_RWLOCK_INITIALIZER (pthread_rwlock_t){ { 0 }, 0, 0 }
#define _PTHREAD_ATFORK_PREPARE 0