]> rtime.felk.cvut.cz Git - frescor/fosa.git/commitdiff
FOSA-PaRTiKle: minor fixes
authorbrocalv <brocalv@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Mon, 3 Mar 2008 11:43:29 +0000 (11:43 +0000)
committerbrocalv <brocalv@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Mon, 3 Mar 2008 11:43:29 +0000 (11:43 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@1035 35b4ef3e-fd22-0410-ab77-dab3279adceb

src_partikle/fosa_app_def_sched.c
src_partikle/fosa_long_jump.c

index 057e65606dc2755144e2543cd489caf891c451b2..c47296e7a9d3bdf19d9a554c96d03ec7c0a832a2 100644 (file)
@@ -99,9 +99,6 @@ void *fosa_scheduler_main (void * args)
        struct posix_appsched_event event;
        struct timespec current_time;
        posix_appsched_eventset_t accepted_events;
-//     bool active;
-       
-       printf ("SCHEDULER thread=0x%lx\n\n", (unsigned long) pthread_self ());
        
        // accept events which have a callback associated
        posix_appsched_fillset (&accepted_events);
@@ -146,14 +143,15 @@ void *fosa_scheduler_main (void * args)
        clear_actions (&actions);
 
        while (1) {     // scheduler loop
-//             printf ("ACTIONS: timeout(0x%x), handled_signals=0x%x\n", actions.timeout_ptr, fosa_handled_signals.sig);
                if (posix_appsched_execute_actions(&(actions.actions), &fosa_handled_signals, actions.timeout_ptr,
                    &current_time, &event))
-                       perror ("posix_appsched_execute_actions");
+               {
+                 fosa_scheduler_ops.appsched_error 
+                     (fosa_scheduler_data, 0x0, FOSA_ADS_THREAD_NOT_ATTACHED, &actions);
+                 continue;
+               }
                
-//             printf ("\nReceived event=%d. current_time={%ld,%ld}\n", event.event_code, current_time.tv_sec, current_time.tv_nsec);
                clear_actions (&actions);
-               
                switch (event.event_code) {
                        case POSIX_APPSCHED_NEW:
                                fosa_scheduler_ops.new_thread
@@ -164,12 +162,7 @@ void *fosa_scheduler_main (void * args)
 
                                if (!actions.rejected) {
                                        
-/*                                     active = actions.activated;
-                                       int suspend = actions.suspended; */
-// #ifndef CONFIG_URGENCY  
                                        clear_actions (&actions);
-//                                         printf ("NEW: activate (%d), suspend (%d)\n", actions.activated, actions.suspended);
-// // #endif
   
                                        // alloc memory for reply info of 'fosa_ads_invoke_with_data ()'
                                        struct reply_info *reply_mem = malloc (sizeof (struct reply_info));
@@ -256,7 +249,7 @@ void *fosa_scheduler_main (void * args)
                                                 &current_time);
                                break;
 
-                       case POSIX_APPSCHED_ERROR:
+                       case POSIX_APPSCHED_ERROR: // Implemented using the usual error handling mechanism
                                fosa_scheduler_ops.appsched_error 
                                        (fosa_scheduler_data, 
                                         event.thread, 
@@ -281,10 +274,6 @@ int fosa_ads_scheduler_create
        pthread_attr_t attr;
        struct sched_param sp;
        
-       
-       printf ("\nMAIN thread=0x%lx\n\n", (unsigned long)pthread_self ());
-       
-       
        if (!scheduler_ops)
                return EINVAL;
        fosa_scheduler_ops = *scheduler_ops;
@@ -469,7 +458,7 @@ int fosa_adsactions_add_activate
        pthread_getschedparam (thread, &policy, &sp);
        fosa_thread_get_prio (thread, &fosaprio);
        sp.sched_priority =  fosa2prtk (fosaprio, urgency);
-       printf ("policy=%d, prio=%d, urg=%d, new_prio=%d\n", policy);
+//     printf ("policy=%d, prio=%d, urg=%d, new_prio=%d\n", policy);
        pthread_setschedparam (thread, policy, &sp);
 #endif
        return posix_appsched_actions_addactivate (&(sched_actions -> actions), thread);
index 446207474bac4d68b022a5d57c8ac6ef88f99ad3..becd66df4e63b88691dea1c8100d890f0bb19b05 100644 (file)
@@ -49,7 +49,7 @@
 // however invalidate any other reasons why the executable file might be
 // covered by the GNU Public License.
 // -----------------------------------------------------------------------
-//fosa_long_jump.h
+//fosa_long_jump.c
 //==============================================
 //  ********  ******    ********  **********
 //  **///// /**    **  **//////  /**     /**
 
 enum {
   LONGJMP_MAGIC = 0x01234567,
-  LONGJMP_NSIG = 3,
-  LONGJMP_FIRSTSIG = SIGRTMIN + 1,
 };
 
 int jmp_used_signals [LONGJMP_NSIG] = {[0 ... (LONGJMP_NSIG - 1)] = 0};
+pthread_mutex_t signal_pool_m = PTHREAD_MUTEX_INITIALIZER
 
 
 int fosa_long_jump_save_context
@@ -113,7 +112,7 @@ void jmp_handler (int signo, siginfo_t *info, void *context)
   sigset_t set;
 
 #ifdef CONFIG_LONGJUMP_FREE_SIGNALS
-  // Restore the signal mask beofre the context save
+  // Restore the signal mask
   pthread_sigmask (SIG_SETMASK, &(context -> jmp_sigmask), NULL);
 
   // Free this signal
@@ -121,9 +120,9 @@ void jmp_handler (int signo, siginfo_t *info, void *context)
   sigaddset (&set, signo);
   pthread_sigmask (SIG_BLOCK, &sigmask, NULL);
 
-  pthread_mutex_lock ();
+  pthread_mutex_lock (&signal_pool_m);
   jmp_used_signals [signo] = 0;
-  pthread_mutex_unlock ();
+  pthread_mutex_unlock (&signal_pool_m);
 #endif
 
   // Restore the saved context
@@ -140,12 +139,15 @@ int fosa_long_jump_install_handler
   sigset_t sigmask;
 
   // Find the first usable signal
-  //  FIXME: Should be atomical
+  pthread_mutex_lock (&signal_pool_m);
   for (i = 0; i < LONGJMP_NSIG && jmp_used_signals [i]; i++);
-  if (i >= LONGJMP_NSIG)
+  if (i >= LONGJMP_NSIG) {
+    pthread_mutex_unlock (&signal_pool_m);
     return FOSA_ENOMEM;
+  }
 
   jmp_used_signals [i] = 1;
+  pthread_mutex_unlock (&signal_pool_m);
 
   *signal = LONGJMP_FIRSTSIG + i;
   *handler = pthread_self ();