//================================================
-
+// MISSED: HEADERS
/********************************
* Application-defined scheduling
extern fosa_ads_scheduler_ops_t fosa_scheduler_operations; // See rtl_appsched.c
-void (*fosa_scheduler_loop)(void *arg); // See rtl_appsched.c
+extern void *fosa_scheduler_loop(void *arg); // See rtl_appsched.c
extern void *fosa_scheduler_args;
extern int fosa_scheduler_args_size;
int ret;
// There will be only ONE single ADS scheduler facility in the system
-
-
- fosa_scheduler_args_size = init_args_size
- fosa_scheduler_args = rtl_malloc(init_args_size);
+ fosa_scheduler_args_size=init_args_size;
+ fosa_scheduler_args=rtl_malloc(init_args_size);
if (!fosa_scheduler_args) {
rtl_printf("ERROR: fosa_ads_scheduler_create, rtl_mallox failed\n");
return -1;
}
- memcpy(fosa_scheduler_args, init_args, init_args_size);
-
- fosa_scheduler_operations = * scheduler_ops;
+ memcpy((unsigned char *)fosa_scheduler_args,
+ (unsigned char *)init_args, init_args_size);
+
+ fosa_scheduler_operations = *scheduler_ops;
pthread_attr_init (&attr);
- sched_param.sched_priority = 100; // Only one priority will be
+ sched_param.sched_priority=100; // Only one priority will be
// used in the system.
- pthread_attr_setappschedulerstate(&attr,PTHREAD_APPSCHEDULER);
+ pthread_attr_setappschedulerstate(&attr, PTHREAD_APPSCHEDULER);
pthread_attr_setschedparam (&attr, &sched_param);
-
- if ( (ret = pthread_create (&fosa_scheduler_thread, &attr, fosa_scheduler_loop , NULL)) ){
- return ret;
- }
-
+
+ ret=pthread_create(&fosa_scheduler_thread, &attr,
+ fosa_scheduler_loop, NULL);
+ return ret;
}
int fosa_thread_attr_set_appscheduled (frsh_thread_attr_t *attr,
- bool appscheduled){
- if (attr){
- if (appscheduled)
- attr->policy=SCHED_APP;
- else
- attr->policy=SCHED_FIFO;
- return 0;
- }
- else return EINVAL;
+ bool appscheduled){
+ if (attr){
+ if (appscheduled)
+ attr->policy=SCHED_APP;
+ else
+ attr->policy=SCHED_FIFO;
+ return 0;
+ }
+ else return EINVAL;
}
int fosa_thread_attr_get_appscheduled (const frsh_thread_attr_t *attr,
bool *appscheduled){
if (attr){
- if (attr->policy==SCHED_APP)
- *appscheduled=true;
- else
- *appscheduled=false;
- return 0;
+ if (attr->policy==SCHED_APP)
+ *appscheduled=true;
+ else
+ *appscheduled=false;
+ return 0;
}
else return EINVAL;
}
int fosa_thread_attr_set_appsched_params (frsh_thread_attr_t *attr,
const void *param,
int paramsize){
- return pthread_attr_setappschedparam(attr, param, paramsize);
+ return pthread_attr_setappschedparam(attr, param, paramsize);
}
int fosa_thread_attr_get_appsched_params (const frsh_thread_attr_t *attr,
void *param,
size_t *paramsize){
- return pthread_attr_getappschedparam(attr, param, paramsize);
+ return pthread_attr_getappschedparam(attr, param, paramsize);
}
int fosa_ads_set_appscheduled (frsh_thread_id_t thread,
- bool appscheduled){
- if (thread){
- if (appscheduled)
- thread->policy=SCHED_APP;
- else
- thread->policy=SCHED_FIFO;
- return 0;
- }
- else return EINVAL;
+ bool appscheduled){
+ pthread_t sched=(appscheduled)?fosa_scheduler_thread:0;
+
+ return (!pthread_setappscheduler(thread, sched))?0:EINVAL;
}
int fosa_ads_get_appscheduled (frsh_thread_id_t thread,
- bool *appscheduled){
- if (thread){
- if (thread->policy==SCHED_APP)
- *appscheduled=true;
- else
- *appscheduled=false;
- return 0;
- }
- else return EINVAL;
+ bool *appscheduled){
+ if (thread) {
+ *appscheduled=(appscheduler(thread))?1:0;
+ return 0;
+ }
+ return EINVAL;
}
int fosa_ads_set_appschedparam (frsh_thread_id_t thread,
const void *param,
size_t paramsize){
- return pthread_setappschedparam(thread, param, paramsize);
+ return (!pthread_setappschedparam(thread, param, paramsize))?0:EINVAL;
}
int fosa_ads_get_appsched_params (frsh_thread_id_t thread,
void *param,
int *paramsize){
- return pthread_getappschedparam(thread, param, paramsize);
+ return (!pthread_getappschedparam(thread, param, paramsize))?0:EINVAL;
}
/*********************************
int fosa_adsactions_add_reject(fosa_ads_actions_t *sched_actions,
frsh_thread_id_t thread){
- return posix_appsched_actions_addreject(sched_actions, thread);
+ return posix_appsched_actions_addreject(sched_actions, thread);
}
-int fosa_adsactions_add_activate(
- fosa_ads_actions_t *sched_actions,
- frsh_thread_id_t thread,
- fosa_ads_urgency_t urgency){
- RTL_PRIO(&thread) = set_urgency(urgency, (&thread));
- return posix_appsched_actions_addactivate(sched_actions, thread);
+int fosa_adsactions_add_activate(fosa_ads_actions_t *sched_actions,
+ frsh_thread_id_t thread,
+ fosa_ads_urgency_t urgency){
+ RTL_PRIO(&thread)=set_urgency(urgency, (&thread));
+ return posix_appsched_actions_addactivate(sched_actions, thread);
}
int fosa_adsactions_add_suspend(fosa_ads_actions_t *sched_actions,
frsh_thread_id_t thread){
- return posix_appsched_actions_addsuspend (sched_actions, thread);
+ return posix_appsched_actions_addsuspend (sched_actions, thread);
}
-int fosa_adsactions_add_timeout(
- fosa_ads_actions_t *sched_actions,
- fosa_clock_id_t clock_id,
- const struct timespec *at_time){
- To be added;
-}
+int fosa_adsactions_add_timeout(fosa_ads_actions_t *sched_actions,
+ fosa_clock_id_t clock_id,
+ const struct timespec *at_time){
+ struct sigevent signal;
+ if (fosa_timeout_timer)
+ return EINVAL;
+ signal.sigev_signo=0;
+ signal.sigev_notify=SIGEV_NONE;
+
+ timer_create(clock_id, signal, &fosa_timeout_timer);
+ timer_settime(fosa_timeout_timer, int flags, at_time, 0);
+}
-int fosa_adsactions_add_thread_notification(
- fosa_ads_actions_t *sched_actions,
- frsh_thread_id_t thread,
- fosa_clock_id_t clock_id,
- const struct timespec *at_time){
+int fosa_adsactions_add_thread_notification(fosa_ads_actions_t *sched_actions,
+ frsh_thread_id_t thread,
+ fosa_clock_id_t clock_id,
+ const struct timespec *at_time){
+
To be added;
}