All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Gerum <rpm@xenomai.org>
To: Stefan Kisdaroczi <kisda@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] rt_task_bind() and timeout values
Date: Thu, 17 Jul 2008 23:58:51 +0200	[thread overview]
Message-ID: <487FC09B.4030202@domain.hid> (raw)
In-Reply-To: <487F26A5.1040908@domain.hid>

Stefan Kisdaroczi wrote:
> your new patch works with TM_NONBLOCK und user timeouts,
> but bind now fails for TM_INFINITE: it returns immediately with
> ETIMEDOUT...
>

Yeah, I should not be working at night. The nucleus does not like the idea of an
infinite timeout value in absolute mode. I need to think a bit about the
consequences of allowing this at core level, so we would not have to expect the
same issue with any interface converting relative timeouts to absolute ones.

The work around for the registry issue is this one, but I don't like it actually:

-        xnsynch_sleep_on(&registry_hash_synch, timeout, XN_REALTIME);
+        xnsynch_sleep_on(&registry_hash_synch, timeout, timeout == XN_INFINITE
? XN_RELATIVE : XN_REALTIME);

More later.

> Philippe Gerum schrieb:
>> Stefan Kisdaroczi wrote:
>>> Hi,
>>>
>>> your patch didnt work. The bind_calls are now blocking infinite (at
>>> least much too long, still waiting...)
>>> To compile i had to change following line in your patch:
>>> -    if (timeout != TM_NONBLOCK && timeout != TM_INFINITE)
>>> +    if (timeout != XN_NONBLOCK && timeout != XN_INFINITE)
>>>
>>
>> Ok, fair enough. This one has been tested. No kidding.
>>
>> --- ksrc/nucleus/registry.c    (revision 4050)
>> +++ ksrc/nucleus/registry.c    (revision 4051)
>> @@ -711,7 +711,6 @@
>>      xnobject_t *object;
>>      xnthread_t *thread;
>>      xntbase_t *tbase;
>> -    xnticks_t stime;
>>      int err = 0;
>>      spl_t s;
>>
>> @@ -723,7 +722,8 @@
>>
>>      xnlock_get_irqsave(&nklock, s);
>>
>> -    stime = xntbase_get_time(tbase);
>> +    if (timeout != XN_INFINITE && timeout != XN_NONBLOCK)
>> +        timeout += xntbase_get_time(tbase);
>>
>>      for (;;) {
>>          object = registry_hash_find(key);
>> @@ -738,18 +738,8 @@
>>              goto unlock_and_exit;
>>          }
>>
>> -        if (timeout != XN_INFINITE) {
>> -            xnticks_t now = xntbase_get_time(tbase);
>> -
>> -            if (stime + timeout >= now)
>> -                break;
>> -
>> -            timeout -= (now - stime);
>> -            stime = now;
>> -        }
>> -
>>          thread->registry.waitkey = key;
>> -        xnsynch_sleep_on(&registry_hash_synch, timeout, XN_RELATIVE);
>> +        xnsynch_sleep_on(&registry_hash_synch, timeout, XN_REALTIME);
>>
>>          if (xnthread_test_info(thread, XNTIMEO)) {
>>              err = -ETIMEDOUT;
>>
>>> I will use following patch for the moment, this works.
>>>
>>> --- xenomai/nucleus/registry.c.old    2008-07-15 00:36:10.000000000
>>> +0200
>>> +++ xenomai/nucleus/registry.c    2008-07-15 15:28:23.000000000 +0200
>>> @@ -733,8 +733,10 @@ int xnregistry_bind(const char *key, xnt
>>>          if (timeout != XN_INFINITE) {
>>>              xnticks_t now = xntbase_get_time(tbase);
>>>
>>> -            if (stime + timeout >= now)
>>> -                break;
>>> +            if (stime + timeout <= now) {
>>> +                err = -ETIMEDOUT;
>>> +                goto unlock_and_exit;
>>> +            }      
>>>              timeout -= (now - stime);
>>>              stime = now;
>>>
>>>
>>> Philippe Gerum schrieb:
>>>> Stefan Kisdaroczi wrote:
>>>>> Hi Philippe,
>>>>>
>>>>> the attached patch fixed the problem for me.
>>>> Good spot. Now it's official, since four years that feature exists or
>>>> so, nobody
>>>> actually used registry timeouts... Oh, well...
>>>>
>>>>> However, i think that in the "break case" still EACCES is returned.
>>>>> Can the break be replaced with a "return ETIMEDOUT" ?
>>>>>
>>>> Yes, normally we should do that along with your patch. Actually, the
>>>> most
>>>> appropriate fix would be to use an absolute timeout value internally,
>>>> since the
>>>> nucleus allows it.
>>>>
>>>> --- ksrc/nucleus/registry.c    (revision 4044)
>>>> +++ ksrc/nucleus/registry.c    (working copy)
>>>> @@ -711,7 +711,6 @@
>>>>      xnobject_t *object;
>>>>      xnthread_t *thread;
>>>>      xntbase_t *tbase;
>>>> -    xnticks_t stime;
>>>>      int err = 0;
>>>>      spl_t s;
>>>>
>>>> @@ -723,7 +722,8 @@
>>>>
>>>>      xnlock_get_irqsave(&nklock, s);
>>>>
>>>> -    stime = xntbase_get_time(tbase);
>>>> +    if (timeout != TM_NONBLOCK && timeout != TM_INFINITE)
>>>> +        timeout += xntbase_get_time(tbase);
>>>>
>>>>      for (;;) {
>>>>          object = registry_hash_find(key);
>>>> @@ -738,18 +738,8 @@
>>>>              goto unlock_and_exit;
>>>>          }
>>>>
>>>> -        if (timeout != XN_INFINITE) {
>>>> -            xnticks_t now = xntbase_get_time(tbase);
>>>> -
>>>> -            if (stime + timeout >= now)
>>>> -                break;
>>>> -
>>>> -            timeout -= (now - stime);
>>>> -            stime = now;
>>>> -        }
>>>> -
>>>>          thread->registry.waitkey = key;
>>>> -        xnsynch_sleep_on(&registry_hash_synch, timeout, XN_RELATIVE);
>>>> +        xnsynch_sleep_on(&registry_hash_synch, timeout, XN_ABSOLUTE);
>>>>
>>>>          if (xnthread_test_info(thread, XNTIMEO)) {
>>>>              err = -ETIMEDOUT;
>>>>  --
>>>> Philippe.
>>>>
>>>>
>>>
>>
>>
> 
> 


-- 
Philippe.


  reply	other threads:[~2008-07-17 21:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-14 17:22 [Xenomai-help] rt_task_bind() and timeout values Stefan Kisdaroczi
2008-07-14 17:50 ` Philippe Gerum
2008-07-14 19:03   ` Stefan Kisdaroczi
2008-07-14 20:35     ` Philippe Gerum
2008-07-15  0:38       ` Stefan Kisdaroczi
2008-07-15  6:25         ` Philippe Gerum
2008-07-16 10:25           ` Stefan Kisdaroczi
2008-07-16 21:17             ` Philippe Gerum
2008-07-17 11:01               ` Stefan Kisdaroczi
2008-07-17 21:58                 ` Philippe Gerum [this message]
2008-07-15 14:28         ` Stefan Kisdaroczi

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=487FC09B.4030202@domain.hid \
    --to=rpm@xenomai.org \
    --cc=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.