Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable priority inheritance for RTT mutexes (gnulinux) #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 22 additions & 10 deletions rtt/os/gnulinux/fosi.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extern "C"
* This function should return ticks,
* but we use ticks == nsecs in userspace
*/
static inline NANO_TIME rtos_get_time_ticks()
static inline NANO_TIME rtos_get_time_ticks(void)
{
return rtos_get_time_ns();
}
Expand Down Expand Up @@ -205,7 +205,17 @@ extern "C"

static inline int rtos_mutex_init(rt_mutex_t* m)
{
return pthread_mutex_init(m, 0 );
pthread_mutexattr_t attr;
int ret = pthread_mutexattr_init(&attr);
if (ret != 0) return ret;

ret = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
if (ret != 0) return ret;

ret = pthread_mutex_init(m, &attr);

pthread_mutexattr_destroy(&attr);
return ret;
}

static inline int rtos_mutex_destroy(rt_mutex_t* m )
Expand All @@ -222,6 +232,8 @@ extern "C"
// make mutex recursive
ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
if (ret != 0) return ret;
ret = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
if (ret != 0) return ret;

ret = pthread_mutex_init(m, &attr);

Expand Down Expand Up @@ -304,14 +316,6 @@ extern "C"
return pthread_mutex_unlock(m);
}

static inline void rtos_enable_rt_warning()
{
}

static inline void rtos_disable_rt_warning()
{
}

typedef pthread_cond_t rt_cond_t;

static inline int rtos_cond_init(rt_cond_t *cond)
Expand Down Expand Up @@ -354,6 +358,14 @@ extern "C"
return pthread_cond_broadcast(cond);
}

static inline void rtos_enable_rt_warning(void)
{
}

static inline void rtos_disable_rt_warning(void)
{
}

#define rtos_printf printf

#ifdef __cplusplus
Expand Down