kernel: POSIX: Compatibility layer for POSIX read-write lock APIs.

This patch provides POSIX read-write lock APIs for POSIX 1003.1
PSE52 standard.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
This commit is contained in:
Youvedeep Singh 2018-02-28 15:37:00 +05:30 committed by Anas Nashif
commit 216883ca82
5 changed files with 350 additions and 0 deletions

View file

@ -411,6 +411,26 @@ static inline int pthread_equal(pthread_t pt1, pthread_t pt2)
return (pt1 == pt2);
}
/**
* @brief Destroy the read-write lock attributes object.
*
* See IEEE 1003.1
*/
static inline int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
{
return 0;
}
/**
* @brief initialize the read-write lock attributes object.
*
* See IEEE 1003.1
*/
static inline int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
{
return 0;
}
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
@ -437,5 +457,17 @@ int pthread_attr_setschedparam(pthread_attr_t *attr,
const struct sched_param *schedparam);
int pthread_setschedparam(pthread_t pthread, int policy,
const struct sched_param *param);
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
int pthread_rwlock_init(pthread_rwlock_t *rwlock,
const pthread_rwlockattr_t *attr);
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock,
const struct timespec *abstime);
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock,
const struct timespec *abstime);
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
#endif /* __PTHREAD_H__ */

View file

@ -63,6 +63,16 @@ typedef u32_t clockid_t;
typedef unsigned long timer_t;
typedef unsigned long useconds_t;
typedef u32_t pthread_rwlockattr_t;
typedef struct pthread_rwlock_obj {
struct k_sem rd_sem;
struct k_sem wr_sem;
struct k_sem reader_active;/* blocks WR till reader has acquired lock */
s32_t status;
k_tid_t wr_owner;
} pthread_rwlock_t;
#endif /* CONFIG_PTHREAD_IPC */
#ifdef __cplusplus