]> rtime.felk.cvut.cz Git - frescor/fosa.git/commitdiff
in newthread callback we must accept the thread before adding any other action
authorsangorrin <sangorrin@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Tue, 10 Jul 2007 11:50:15 +0000 (11:50 +0000)
committersangorrin <sangorrin@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Tue, 10 Jul 2007 11:50:15 +0000 (11:50 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@518 35b4ef3e-fd22-0410-ab77-dab3279adceb

src_marte/fosa_app_def_sched.c

index 0a34eb3957ff1472825ceaa470b2a2ab82d3be59..9f2b761a81a760c91122701f49a34cc419d8f9df 100644 (file)
 //
 // FOSA(Frescor Operating System Adaptation layer)
 //================================================
-// 26-6-07 SANGORRIN: comment scheduler mutex because signal_set can only be
+// 26-Jun-07 SANGORRIN: comment scheduler mutex because signal_set can only be
 // set from the scheduler itself (don't delete because it might be useful in
 // the future).
 //
-// 25-6-07 SANGORRIN: when posix_appsched_execute_actions had an error the code
+// 25-Jun-07 SANGORRIN: when posix_appsched_execute_actions had an error code
 // was wrong. Now we clear actions before (and added destroy operation!), then
 // execute scheduler op and then go back to main loop (when error it continued
 // executing the rest of actions)
+//
+// 10-Jul-07 SANGORRIN: in the new_thread callback we need to accept the thread
+// before suspend or activate it.
 // -----------------------------------------------------------------------
 
 #include "fosa_app_def_sched.h"
@@ -254,13 +257,20 @@ void * scheduler_thread_code(void *arg) {
                      CHK(posix_appsched_actions_addreject
                         (&(sched_actions.actions),event.thread));
                   } else {
+                     // clear actions, we need to accept the thread first
+                     CHK(posix_appsched_actions_destroy (&(sched_actions.actions)));
+                     CHK(posix_appsched_actions_init(&(sched_actions.actions)));
+                     // accept the thread
                      CHK(posix_appsched_actions_addaccept
                         (&(sched_actions.actions),event.thread));
                      // store the memory area in thread-specific data
                      CHK(pthread_setspecific_for
                         (schedthreaddata.msg_key,event.thread,call_info));
-                     // activate the thread unless suspended or already activated
-                     if (!sched_actions.suspended && !sched_actions.activated) {
+                     // and activate or suspend the thread
+                     if (sched_actions.suspended) {
+                        CHK(posix_appsched_actions_addsuspend
+                           (&(sched_actions.actions),event.thread));
+                     } else {
                         CHK(posix_appsched_actions_addactivate
                            (&(sched_actions.actions),event.thread));
                      }