All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Kisdaroczi <kisda@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] question about task migrating to primary mode
Date: Wed, 11 Jan 2006 22:56:35 +0100	[thread overview]
Message-ID: <200601112256.41723.kisda@domain.hid> (raw)

[-- 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 --]

             reply	other threads:[~2006-01-11 21:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-11 21:56 Stefan Kisdaroczi [this message]
2006-01-11 23:03 ` [Xenomai-help] question about task migrating to primary mode Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200601112256.41723.kisda@domain.hid \
    --to=kisda@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.