All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] question about task migrating to primary mode
@ 2006-01-11 21:56 Stefan Kisdaroczi
  2006-01-11 23:03 ` Jan Kiszka
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Kisdaroczi @ 2006-01-11 21:56 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 1816 bytes --]

Hi,

I have a question about migrating a task to primary mode.

Following code is from Captain's  "Hard Real Time Serial Port (RS232) 
Example" [1]:
...
  while (1) {
    /* switch to primary mode */
    ret = rt_task_set_mode(0, T_PRIMARY, NULL);
    if (ret) {
      printf(WTASK_PREFIX "error while rt_task_set_mode, code %d\n",ret);
      goto exit_write_task;
    }
    ret = rt_task_wait_period();
    if (ret) {
      printf(WTASK_PREFIX "error while rt_task_wait_period, code %d\n",ret);
      goto exit_write_task;
    }
    sz = sizeof(buf);
    written = rt_dev_write(my_fd, &buf, sizeof(buf));
    printf(WTASK_PREFIX "rt_dev_write written=%d sz=%d\n", written, sz);
    if (written != sz ) {
      if (written < 0 ) {
        printf(WTASK_PREFIX "error while rt_dev_write, code %d\n",written);
      } else {
        printf(WTASK_PREFIX "only %d / %d byte transmitted\n",written, sz);
      }
      goto exit_write_task;
    }
  }
...

Is the rt_task_set_mode(0, T_PRIMARY, NULL) call really necessary?
I seems the call is used here to migrate to task back to primary mode if a 
error-"printf" switched the task to secondary mode.

From the "Native API Tour"-Document, page 8 [2]:
"By convention, all Xenomai services which
might block the caller cause such transition when necessary; in other words, real­
time tasks blocked on Xenomai resources are always aslept in primary mode."

As the next call is rt_task_wait_period which should block, i think its not 
necessary to force a migration "by hand" to primary mode. Is this true ?

Thank you Hannes for all your examples.

Thanks
kisda

[1] http://www.captain.at/xenomai-serial-port-example.php
[2] 
http://snail.fsffrance.org/www.xenomai.org/documentation/branches/v2.0.x/pdf/Native-API-Tour.pdf

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-11 23:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-11 21:56 [Xenomai-help] question about task migrating to primary mode Stefan Kisdaroczi
2006-01-11 23:03 ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.