git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1550
35b4ef3e-fd22-0410-ab77-
dab3279adceb
size_t scheduler_data_size, void * init_args,
size_t init_args_size)
{
size_t scheduler_data_size, void * init_args,
size_t init_args_size)
{
int fosa_thread_attr_set_appscheduled(fosa_thread_attr_t *attr,
bool appscheduled)
{
int fosa_thread_attr_set_appscheduled(fosa_thread_attr_t *attr,
bool appscheduled)
{
int fosa_thread_attr_get_appscheduled(const fosa_thread_attr_t *attr,
bool *appscheduled)
{
int fosa_thread_attr_get_appscheduled(const fosa_thread_attr_t *attr,
bool *appscheduled)
{
const void *param,
size_t paramsize)
{
const void *param,
size_t paramsize)
{
int fosa_thread_attr_get_appsched_params(const fosa_thread_attr_t *attr,
void *param, size_t *paramsize)
{
int fosa_thread_attr_get_appsched_params(const fosa_thread_attr_t *attr,
void *param, size_t *paramsize)
{
**/
int fosa_ads_set_appscheduled(fosa_thread_id_t thread, bool appscheduled)
{
**/
int fosa_ads_set_appscheduled(fosa_thread_id_t thread, bool appscheduled)
{
**/
int fosa_ads_get_appscheduled(fosa_thread_id_t thread, bool *appscheduled)
{
**/
int fosa_ads_get_appscheduled(fosa_thread_id_t thread, bool *appscheduled)
{
int fosa_ads_set_appsched_params(fosa_thread_id_t thread,
const void *param, size_t paramsize)
{
int fosa_ads_set_appsched_params(fosa_thread_id_t thread,
const void *param, size_t paramsize)
{
int fosa_ads_get_appsched_params(fosa_thread_id_t thread,
void *param, size_t *paramsize)
{
int fosa_ads_get_appsched_params(fosa_thread_id_t thread,
void *param, size_t *paramsize)
{
int fosa_adsactions_add_reject(fosa_ads_actions_t *sched_actions,
fosa_thread_id_t thread)
{
int fosa_adsactions_add_reject(fosa_ads_actions_t *sched_actions,
fosa_thread_id_t thread)
{
fosa_thread_id_t thread,
fosa_ads_urgency_t urgency)
{
fosa_thread_id_t thread,
fosa_ads_urgency_t urgency)
{
int fosa_adsactions_add_suspend(fosa_ads_actions_t *sched_actions,
fosa_thread_id_t thread)
{
int fosa_adsactions_add_suspend(fosa_ads_actions_t *sched_actions,
fosa_thread_id_t thread)
{
fosa_clock_id_t clock_id,
const fosa_abs_time_t *at_time)
{
fosa_clock_id_t clock_id,
const fosa_abs_time_t *at_time)
{
fosa_clock_id_t clock_id,
const fosa_abs_time_t *at_time)
{
fosa_clock_id_t clock_id,
const fosa_abs_time_t *at_time)
{
**/
int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size)
{
**/
int fosa_ads_set_handled_signal_set(fosa_signal_t set[], int size)
{
**/
int fosa_signal_queue_scheduler(fosa_signal_t signal, fosa_signal_info_t info)
{
**/
int fosa_signal_queue_scheduler(fosa_signal_t signal, fosa_signal_info_t info)
{
int fosa_ads_invoke_withdata(const void *msg, size_t msg_size,
void *reply, size_t *reply_size)
{
int fosa_ads_invoke_withdata(const void *msg, size_t msg_size,
void *reply, size_t *reply_size)
{
* notify it to the system console and then terminate the FRSH
* implementation and dependant applications
**/
* notify it to the system console and then terminate the FRSH
* implementation and dependant applications
**/
-int fosa_rel_timer_arm (fosa_timer_id_t timerid, const fosa_rel_time_t *value)
+int fosa_rel_timer_arm(fosa_timer_id_t timerid, const fosa_rel_time_t *value)
{
struct itimerspec when;
{
struct itimerspec when;
struct itimerspec when;
/* non-periodic one shot timer */
struct itimerspec when;
/* non-periodic one shot timer */
- when.it_value= fosa_abs_time_to_timespec(*value);
- when.it_interval=zero_time;
+ when.it_value = fosa_abs_time_to_timespec(*value);
+ when.it_interval = zero_time;
return timer_settime(timerid, TIMER_ABSTIME, &when, NULL);
}
return timer_settime(timerid, TIMER_ABSTIME, &when, NULL);
}
int ret;
struct itimerspec time;
int ret;
struct itimerspec time;
- if (remaining_time == NULL)
return FOSA_EINVAL;
ret = timer_gettime(timerid, &time);
return FOSA_EINVAL;
ret = timer_gettime(timerid, &time);
int ret;
struct itimerspec time;
int ret;
struct itimerspec time;
- if (remaining_time == NULL)
return FOSA_EINVAL;
ret = timer_gettime(timerid, &time);
return FOSA_EINVAL;
ret = timer_gettime(timerid, &time);
**/
int fosa_thread_set_create(fosa_thread_set_id_t *set)
{
**/
int fosa_thread_set_create(fosa_thread_set_id_t *set)
{
**/
int fosa_thread_set_destroy(fosa_thread_set_id_t set)
{
**/
int fosa_thread_set_destroy(fosa_thread_set_id_t set)
{
**/
int fosa_thread_set_add(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
{
**/
int fosa_thread_set_add(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
{
int fosa_thread_set_del(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
{
int fosa_thread_set_del(fosa_thread_set_id_t set, fosa_thread_id_t thread_id)
{
int fosa_get_groupcpu_clock(const fosa_thread_set_id_t set,
fosa_clock_id_t *clock_id)
{
int fosa_get_groupcpu_clock(const fosa_thread_set_id_t set,
fosa_clock_id_t *clock_id)
{
int fosa_long_jump_was_performed(const fosa_long_jump_context_t *context,
int *jumped)
{
int fosa_long_jump_was_performed(const fosa_long_jump_context_t *context,
int *jumped)
{
**/
void __long_jump_handler(int n, siginfo_t *info, void *c)
{
**/
void __long_jump_handler(int n, siginfo_t *info, void *c)
{
- fosa_long_jump_context_t *context = (fosa_long_jump_context_t*)info->si_ptr;
+ fosa_long_jump_context_t *context =
+ (fosa_long_jump_context_t*) info->si_ptr;
siglongjmp(*context, 1);
}
siglongjmp(*context, 1);
}
int fosa_get_cpu_resource_id(fosa_resource_id_t *cpu_id)
{
int fosa_get_cpu_resource_id(fosa_resource_id_t *cpu_id)
{
* Thread attributes
*************************/
* Thread attributes
*************************/
+static inline int __fosa_check_thread(const fosa_thread_id_t *tid)
+{
+ if (tid->linux_pid == tid->linux_tid)
+ return 0;
+
+ return 1;
+}
+
/**
* fosa_thread_attr_init()
*
/**
* fosa_thread_attr_init()
*
**/
int fosa_thread_attr_init(fosa_thread_attr_t *attr)
{
**/
int fosa_thread_attr_init(fosa_thread_attr_t *attr)
{
- fosa_thread_id_t self;
-
- /* only POSIX threads have attributes */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
-
return pthread_attr_init(attr);
}
return pthread_attr_init(attr);
}
**/
int fosa_thread_attr_destroy(fosa_thread_attr_t *attr)
{
**/
int fosa_thread_attr_destroy(fosa_thread_attr_t *attr)
{
- fosa_thread_id_t self;
-
- /* only POSIX threads can have attributes */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
-
return pthread_attr_destroy(attr);
}
return pthread_attr_destroy(attr);
}
int fosa_thread_attr_set_stacksize(fosa_thread_attr_t *attr,
size_t stacksize)
{
int fosa_thread_attr_set_stacksize(fosa_thread_attr_t *attr,
size_t stacksize)
{
- fosa_thread_id_t self;
-
- /* only POSIX threads can set the size of the stack */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
-
return pthread_attr_setstacksize(attr, stacksize);
}
return pthread_attr_setstacksize(attr, stacksize);
}
int fosa_thread_attr_get_stacksize(const fosa_thread_attr_t *attr,
size_t *stacksize)
{
int fosa_thread_attr_get_stacksize(const fosa_thread_attr_t *attr,
size_t *stacksize)
{
- fosa_thread_id_t self;
-
- /* only POSIX threads can set the size of the stack */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
-
return pthread_attr_getstacksize(attr, stacksize);
}
return pthread_attr_getstacksize(attr, stacksize);
}
{
int i, error = 0;
bool found = false;
{
int i, error = 0;
bool found = false;
- fosa_thread_id_t self;
-
- /* only POSIX threads can have specific data */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
if ((error = pthread_mutex_lock(&key_lock)) != 0)
return error;
if ((error = pthread_mutex_lock(&key_lock)) != 0)
return error;
int fosa_key_destroy(int key)
{
int error;
int fosa_key_destroy(int key)
{
int error;
- fosa_thread_id_t self;
-
- /* only POSIX threads can have specific data */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
if ((error = pthread_mutex_lock(&key_lock)) != 0)
return error;
if ((error = pthread_mutex_lock(&key_lock)) != 0)
return error;
fosa_thread_id_t tid,
const void * value)
{
fosa_thread_id_t tid,
const void * value)
{
- fosa_thread_id_t self;
-
/* only POSIX threads can have specific data */
/* only POSIX threads can have specific data */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
+ if (!__fosa_check_thread(&tid))
return EINVAL;
return pthread_setspecific(key_list[key], value);
return EINVAL;
return pthread_setspecific(key_list[key], value);
fosa_thread_id_t tid,
void ** value)
{
fosa_thread_id_t tid,
void ** value)
{
- fosa_thread_id_t self;
-
/* only POSIX threads can have specific data */
/* only POSIX threads can have specific data */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
+ if (!__fosa_check_thread(&tid))
return EINVAL;
if ((value = pthread_getspecific(key_list[key])) != NULL)
return EINVAL;
if ((value = pthread_getspecific(key_list[key])) != NULL)
int fosa_thread_attr_set_prio(fosa_thread_attr_t *attr, int prio)
{
int error;
int fosa_thread_attr_set_prio(fosa_thread_attr_t *attr, int prio)
{
int error;
struct sched_param param;
struct sched_param param;
- /* normal UNIX processes have no attributes */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
-
param.sched_priority = prio;
if ((error = pthread_attr_setschedpolicy(attr, SCHED_RR)) == 0)
return error;
param.sched_priority = prio;
if ((error = pthread_attr_setschedpolicy(attr, SCHED_RR)) == 0)
return error;
int fosa_thread_attr_get_prio(const fosa_thread_attr_t *attr, int *prio)
{
int error;
int fosa_thread_attr_get_prio(const fosa_thread_attr_t *attr, int *prio)
{
int error;
struct sched_param param;
struct sched_param param;
- /* normal UNIX processes have no attributes */
- self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- return EINVAL;
-
if ((error = pthread_attr_getschedparam(attr, ¶m)) == 0)
*prio = param.sched_priority;
if ((error = pthread_attr_getschedparam(attr, ¶m)) == 0)
*prio = param.sched_priority;
{
struct sched_param param;
{
struct sched_param param;
- param.sched_priority=prio;
-
+ param.sched_priority = prio;
return sched_setscheduler(0, SCHED_RR, ¶m);
}
return sched_setscheduler(0, SCHED_RR, ¶m);
}
int fosa_thread_get_prio(fosa_thread_id_t tid, int *prio)
{
struct sched_param param;
int fosa_thread_get_prio(fosa_thread_id_t tid, int *prio)
{
struct sched_param param;
- error = sched_getparam(0, ¶m);
+ ret = sched_getparam(0, ¶m);
*prio = param.sched_priority;
*prio = param.sched_priority;
}
/*******************************************************************
}
/*******************************************************************
}
self = fosa_thread_self();
}
self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
+ if (__fosa_check_thread(&self))
return pthread_sigmask(SIG_BLOCK, &sigset, NULL);
else
return sigprocmask(SIG_BLOCK, &sigset, NULL);
return pthread_sigmask(SIG_BLOCK, &sigset, NULL);
else
return sigprocmask(SIG_BLOCK, &sigset, NULL);
//================================================
#include "fosa_time.h"
//================================================
#include "fosa_time.h"
+#include "fosa_clocks_and_timers.h"
#include "fosa_threads_and_signals.h"
/**
#include "fosa_threads_and_signals.h"
/**
struct timespec current_time, time_to_go;
self = fosa_thread_self();
struct timespec current_time, time_to_go;
self = fosa_thread_self();
- if (self.linux_pid == self.linux_tid)
- error = clock_getcpuclockid(self.linux_pid, &clock_id);
- else
- error = pthread_getcpuclockid(self.pthread_id, &clock_id);
- if (error != 0)
+ error = fosa_thread_get_cputime_clock(self, &clock_id);
+ if (!error)
return;
if (clock_gettime(clock_id, ¤t_time) != 0)
return;
if (clock_gettime(clock_id, ¤t_time) != 0)