]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - src_marte/fosa_app_def_sched.c
updated test ads and corrected error in appdefsched.c
[frescor/fosa.git] / src_marte / fosa_app_def_sched.c
index 672270d5ce9b576876a77578d8c9a80dd2d24425..86fe0be6aee469d3b72a9dac904ed7a2d46aca72 100644 (file)
@@ -211,7 +211,7 @@ void * scheduler_thread_code(void *arg) {
     copy_of_signalset=sch_thread_data->sch_signal_set;
 
     // unlock the scheduler mutex before waiting
-    CHK(pthread_mutex_lock(&(sch_thread_data->sch_mutex)));
+    CHK(pthread_mutex_unlock(&(sch_thread_data->sch_mutex)));
 
     // execute pending scheduling actions and wait for next event
     err=posix_appsched_execute_actions
@@ -268,7 +268,7 @@ void * scheduler_thread_code(void *arg) {
            if (!sched_actions.suspended && !sched_actions.activated) {
              CHK(posix_appsched_actions_addactivate
                  (&(sched_actions.actions),event.thread));
-           } 
+           }
          }
        }
        break;
@@ -340,7 +340,7 @@ void * scheduler_thread_code(void *arg) {
           clk,
           &sched_actions,
           &current_time);
-       // t.b.d. check if state of thread is suspended by default 
+       // t.b.d. check if state of thread is suspended by default
        break;
       case POSIX_APPSCHED_TIMEOUT:
        sch_thread_data->scheduler_ops.timeout
@@ -412,7 +412,7 @@ int fosa_ads_scheduler_create
   int err;
   struct sched_param param;
 
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check for NULL scheduler operations
   if (scheduler_ops==NULL) {
     return EINVAL;
@@ -498,7 +498,17 @@ int fosa_thread_attr_set_appscheduled
         (frsh_thread_attr_t *attr,
          bool appscheduled)
 {
-  return pthread_attr_setschedpolicy(attr,SCHED_APP);
+    int error_code;
+
+    // set the application-defined scheduler thread
+    error_code=pthread_attr_setappscheduler(attr,scheduler_thread_id);
+    if (error_code!=0) return error_code;
+
+    if (appscheduled) {
+        return pthread_attr_setschedpolicy(attr,SCHED_APP);
+    } else {
+        return pthread_attr_setschedpolicy(attr,SCHED_FIFO);
+    }
 }
 
 /**
@@ -788,7 +798,7 @@ int fosa_adsactions_add_reject(
         fosa_ads_actions_t *sched_actions,
         frsh_thread_id_t thread)
 {
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check errors
   if (!pthread_equal(pthread_self(),scheduler_thread_id)) {
     return FOSA_EPOLICY;
@@ -836,7 +846,7 @@ int fosa_adsactions_add_activate(
         frsh_thread_id_t thread,
         fosa_ads_urgency_t urgency)
 {
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check errors
   struct sched_param param;
   int policy;
@@ -878,7 +888,7 @@ int fosa_adsactions_add_suspend(
         fosa_ads_actions_t *sched_actions,
         frsh_thread_id_t thread)
 {
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check errors
   struct sched_param param;
   int policy;
@@ -956,7 +966,7 @@ int fosa_adsactions_add_thread_notification(
         fosa_clock_id_t clock_id,
         const struct timespec *at_time)
 {
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check errors
   struct sched_param param;
   int policy;
@@ -1012,7 +1022,7 @@ int fosa_ads_set_handled_signal_set(frsh_signal_t set[], int size)
 {
   int i;
 
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check errors
   if (!pthread_equal(pthread_self(),scheduler_thread_id)) {
     return FOSA_EPOLICY;
@@ -1081,7 +1091,7 @@ int fosa_ads_invoke_withdata
   struct explicit_call_info * call_info;
   int error_code;
 
-#ifdef FULL_ERROR_CHECKING  
+#ifdef FULL_ERROR_CHECKING
   // check errors
   if (pthread_equal(pthread_self(),scheduler_thread_id)) {
     return FOSA_EPOLICY;