Skip to contentSkip to conversation

VxWorks mode switching signal SIGXCPU and switch operation

Xenomai-help Matthieu 2 participants 3 messages May 19, 2008 – May 20, 2008

lore
Share & tools
lore

Matthieu

author
#0 lore raw

Hi

I'm using vxwork's API.
Is SIGXCPU signal sent when primary to seconday VxWorks task's mode switch ? If it's the case, which implementation would work ?

Use of signal (native Xenomai API) :

     void vx_task_create(...) 
     {
     ...
     signal(SIGXCPU, xe_signal_thread);
     ...
     }

     void *xe_signal_thread (void *sig_caught)
     {
       /* Mode switching warning */
     }

     There is missing rt_task_set_mode(0, T_WARNSW, NULL); which I don't

know where I have to put it because I want all the task to warn in case of a mode switch and I don't what to write this sentense in each task's body routine.

Use of pthread_sigmask

     static sigset_t sigusr1Mask;

     void vx_task_create(...) 
     {
     ...
     sigemptyset(&sigusr1Mask);
     sigaddset(&sigusr1Mask,SIGXCPU);
     ...
     }

     void vx_task_start(...) {
     ...
     pthread_sigmask (SIG_BLOCK, &sigusr1Mask, NULL);
     pthread_create (&sig_thr_id, NULL, xe_signal_thread, NULL);
     ...
     }

     void *xe_signal_thread (void *arg)
     {
       int       sig_caught;    /* signal caught       */
       sigwait (&signal_mask, &sig_caught);
       switch (sig_caught)
       {
          case SIGXCPU:     /* process SIGXCPU  */
            /* Mode switching warning */
            fprintf (stderr, "\nPrimary to secondary mode switch %d\n",
sig_caught);
            break;
          default:         /* should normally not happen */
            fprintf (stderr, "\nUnexpected signal %d\n", sig_caught);
            break;
       }
     }

     In this case, a thread waiting for the signal will be created with

each task, I don't thing it's necessary !!

On last thing, how can I force a vxworks task switching in primary mode, like in the native API rt_task_set_mode(0, T_WARNSW, NULL);

Thank's in advance

Matthieu

author
#1 lore raw
Quoted 4 lines · Matthieu

Hi

I'm using vxwork's API.
Is SIGXCPU signal sent when primary to seconday VxWorks task's mode

switch

Quoted 17 lines

? If it's the case, which implementation would work ?

Use of signal (native Xenomai API) :

     void vx_task_create(...)
     {
     ...
     signal(SIGXCPU, xe_signal_thread);
     ...
     }

     void *xe_signal_thread (void *sig_caught)
     {
       /* Mode switching warning */
     }

     There is missing rt_task_set_mode(0, T_WARNSW, NULL); which I don't
Quoted 1 line

know where I have to put it because I want all the task to warn in case

of

Quoted 42 lines

a mode switch and I don't what to write this sentense in each task's body routine.

Use of pthread_sigmask

     static sigset_t sigusr1Mask;

     void vx_task_create(...)
     {
     ...
     sigemptyset(&sigusr1Mask);
     sigaddset(&sigusr1Mask,SIGXCPU);
     ...
     }

     void vx_task_start(...) {
     ...
     pthread_sigmask (SIG_BLOCK, &sigusr1Mask, NULL);
     pthread_create (&sig_thr_id, NULL, xe_signal_thread, NULL);
     ...
     }

     void *xe_signal_thread (void *arg)
     {
       int       sig_caught;    /* signal caught       */
       sigwait (&signal_mask, &sig_caught);
       switch (sig_caught)
       {
          case SIGXCPU:     /* process SIGXCPU  */
            /* Mode switching warning */
            fprintf (stderr, "\nPrimary to secondary mode switch %d\n",
sig_caught);
            break;
          default:         /* should normally not happen */
            fprintf (stderr, "\nUnexpected signal %d\n", sig_caught);
            break;
       }
     }

     In this case, a thread waiting for the signal will be created with
Quoted 10 lines

each task, I don't thing it's necessary !!

On last thing, how can I force a vxworks task switching in primary mode, like in the native API rt_task_set_mode(0, T_PRIMARY, NULL);

Thank's in advance

Matthieu

I found out that it is possible to mix API since SIGXCPU signal, sent when swiching in secondary mode, is obviously only used by Xenomai Native API. Well, I tried to implement it in a vxworks context, but I don't have test it yet. I have some problems remaining with rt_task_set_mode(0, T_WARNSW, NULL) that I don't know where to use.
Do you have any solution ?

Matthieu

#2 lore raw
Quoted 3 lines · Matthieu

I found out that it is possible to mix API since SIGXCPU signal, sent when swiching in secondary mode, is obviously only used by Xenomai Native API.

Ok. But you could implement taskOptionsGet/taskOptionsSet to allow setting a VX_WARNSW option bit, and even setting it in taskInit/taskSpawn.

Quoted 4 lines

Well, I tried to implement it in a vxworks context, but I don't have test it yet. I have some problems remaining with rt_task_set_mode(0, T_WARNSW, NULL) that I don't know where to use.
Do you have any solution ?

Well, in a usual application only some tasks are really critical, and only these deserve the T_WARNSW bit. So, yes, you have to know what tasks are really critical, only set the T_WARNSW bit for these and use it to remove any switch to secondary mode.

Signature · 1 line
					    Gilles.