Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*
* pthread
*
* Copyright 2017-2018, 2019 Phoenix Systems
* Author: Pawel Pisarczyk, Michal Miroslaw, Marcin Baran
* Copyright 2017-2018, 2019, 2026 Phoenix Systems
* Author: Pawel Pisarczyk, Michal Miroslaw, Marcin Baran, Adam Greloch
*
* This file is part of Phoenix-RTOS.
*
Expand Down Expand Up @@ -45,8 +45,6 @@ extern "C" {
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1

#define PTHREAD_MUTEX_INITIALIZER { 0, 0 }

#define PTHREAD_MUTEX_NORMAL PH_LOCK_NORMAL
#define PTHREAD_MUTEX_ERRORCHECK PH_LOCK_ERRORCHECK
#define PTHREAD_MUTEX_RECURSIVE PH_LOCK_RECURSIVE
Expand All @@ -58,7 +56,11 @@ extern "C" {
#define PTHREAD_CANCEL_ENABLE 1
#define PTHREAD_CANCELED 2

#define PTHREAD_COND_INITIALIZER { 0, 0 }
/* clang-format off */
#define PTHREAD_MUTEX_INITIALIZER { 0, 0 }
#define PTHREAD_COND_INITIALIZER { 0, 0 }
#define PTHREAD_RWLOCK_INITIALIZER { 0 }
/* clang-format on */


int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
Expand All @@ -76,6 +78,9 @@ int pthread_setcancelstate(int state, int *oldstate);
int pthread_cancel(pthread_t thread);


void pthread_testcancel(void);


pthread_t pthread_self(void);


Expand Down Expand Up @@ -276,9 +281,27 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);


int pthread_rwlock_timedrdlock(pthread_rwlock_t *__restrict__ rwlock, const struct timespec *__restrict__ abs_timeout);


int pthread_rwlock_timedwrlock(pthread_rwlock_t *__restrict__ rwlock, const struct timespec *__restrict__ abs_timeout);


int pthread_rwlock_init(pthread_rwlock_t *__restrict__ rwlock, const pthread_rwlockattr_t *__restrict__ attr);


int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);


int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);


int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *__restrict__ attr, int *__restrict__ pshared);


int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);


#ifdef __cplusplus
}
#endif
Expand Down
16 changes: 13 additions & 3 deletions include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,20 @@ typedef struct {
volatile int initialized;
} pthread_mutex_t;

/* TODO */
typedef int pthread_rwlock_t;
typedef struct {
handle_t lock;
handle_t readCond;
handle_t writeCond;
size_t readActive;
size_t writeActive;
size_t writeWaiting;
volatile int initialized;
} pthread_rwlock_t;
Comment thread
adamgreloch marked this conversation as resolved.


typedef int pthread_rwlockattr_t;
typedef struct {
int pshared;
} pthread_rwlockattr_t;


typedef struct lockAttr pthread_mutexattr_t;
Expand Down
Loading
Loading