//================================================
#include "fosa_time.h"
+#include "fosa_configuration_parameters.h"
#include "fosa_mutexes_and_condvars.h"
#ifdef OMK_FOR_USER /* If compiled by OMK, use the config */
**/
int fosa_mutex_init(fosa_mutex_t *mutex, int prioceiling)
{
- int error;
+ int ret;
pthread_mutexattr_t attr;
- if ((error = pthread_mutexattr_init(&attr)) != 0)
- return error;
+ ret = pthread_mutexattr_init(&attr);
+ if (ret) return errno;
#ifndef CONFIG_NO_PRIO_INHERIT /* Valgrind doesn't support this attribute */
- if ((error = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT)) != 0)
- return error;
+ ret = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
+ if (ret) return errno;
#endif
+
+ ret = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ if (ret) return errno;
+
return pthread_mutex_init(mutex, &attr);
}
int new_ceiling,
int *old_ceiling)
{
- return -EINVAL;
+ return FOSA_EINVAL;
}
/**
**/
int fosa_mutex_get_prioceiling(const fosa_mutex_t *mutex, int *ceiling)
{
- return -EINVAL;
+ return FOSA_EINVAL;
}
/**
**/
int fosa_cond_init(fosa_cond_t *cond)
{
- return pthread_cond_init(cond, NULL);
+ int ret;
+ pthread_condattr_t attr;
+
+ ret = pthread_condattr_init(&attr);
+ if (ret) return errno;
+
+ ret = pthread_condattr_setclock(&attr, FOSA_CLOCK_REALTIME);
+ if (ret) return errno;
+
+ ret = pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ if (ret) return errno;
+
+ return pthread_cond_init(cond, &attr);
}
/**
struct timespec abstime_tspec;
abstime_tspec = fosa_abs_time_to_timespec(*abstime);
-
return pthread_cond_timedwait(cond, mutex, &abstime_tspec);
}
+