From: Philippe Gerum <rpm@xenomai.org>
To: Klaas Gadeyne <klaas.gadeyne@domain.hid>
Cc: xenomai@xenomai.org, Jan Kiszka <jan.kiszka@domain.hid>
Subject: Re: [Xenomai-help] rt_task_sleep_until question
Date: Wed, 23 Apr 2008 13:37:53 +0200 [thread overview]
Message-ID: <480F1F91.7040502@domain.hid> (raw)
In-Reply-To: <Pine.LNX.4.64.0804231320210.28489@domain.hid>
Klaas Gadeyne wrote:
> On Tue, 22 Apr 2008, Philippe Gerum wrote:
>
> [snipping even more context]
>
>>>> What's wrong with rt_task_suspend() ?
>>>
>>> The current loop code is something like
>>>
>>> void timerloop_task_proc(void *arg)
>>> {
>>> int ret;
>>> int errors = 0;
>>> do{
>>> do{
>>> last_occured_alarm = last_alarm_set;
>>> EnterMutex();
>>> TimeDispatch();
>>> LeaveMutex();
>>> }while ((ret = rt_task_sleep_until(last_alarm)) == 0);
>>> if (ret == -ETIMEDOUT){
>>> printf("[TIMERLOOP] Total errors = %d, return code =
>>> %d\n",++errors,ret);
>>> }
>>> }while (!(stop_timer && ret == -EINTR));
>>> printf("End of TimerLoop, code %d, Total errors =
>>> %d\n",ret,errors);
>>> }
>>>
>>> I could modify that code and put something like
>>> if (last_alarm == TIMEVAL_MAX) // Nothing else to do, sleep forever
>>> rt_task_suspend()
>>> else
>>> rt_task_sleep_until(last_alarm)
>>>
>>> However, the one who wants to wake up this thread (e.g. for asking
>>> this thread to stop) doesn't know in what state the timerthread is.
>>> It seems clumsy to me if that the one who wants to wake up the thread
>>> has to try _unblock() first, and the _resume()?
>>>
>>
>> There has been a fair amount of misunderstanding. Past mails were
>> apparently
>> aiming at rt_task_sleep's behaviour (e.g. returning 0 on NULL delay
>> etc.), but
>> you actually care for rt_task_sleep_until, which is a totally
>> different story
>> (the subject line was right though).
>
> Sorry about that, during the debugging I ended up playing around with
> rt_task_sleep() to check if the overflow issues did occur there too.
>
>> Handling the special TM_INFINITE value as a valid timeout value for
>> rt_task_sleep_until would not introduce the flaws I was concerned about
>> regarding rt_task_sleep. We would just change the behaviour when
>> receiving what
>> used to be an utterly bugous date spec in the current implementation,
>> and make
>> it valid, which is ok -- i.e. I'm not particularly concerned by
>> maintaining
>> backward compatible behaviours when receiving utterly insane data
>> specs like "0"
>> for an absolute date.
>>
>> If your loop was truly periodic, you could probably use
>> rt_task_wait_period(),
>> but I suspect last_alarm may not try to enforce a strictly periodic
>> timeline, right?
>>
>> The fact that we don't have any other blocking calls with absolute
>> date specs is
>> bothering me actually, and 2.5 will probably see some extensions like
>> rt_sem_p_until(), in order to address patterns of this kind.
>>
>> But well, back to rt_task_sleep_until, I see no reason not to handle
>> the corner
>> case you described a bit more gracefully. So let's try the Klaas
>> Amendment to
>> the native API.
>
> I *really* like the way that sounds ;-)
>
>> Does the following work for you?
>
> [snipped patch]
>
> It does! Tested on today's 2.4-branch on a 2.6.20.21-ipipe-1.12-03 kernel.
> Any chance this could still be merged in the 2.4 series?
>
Since this does not change the behaviour of documented and valid use cases, I
will merge that patch into 2.4.4.
> Thx for your patience!
>
You are welcome.
> Klaas
>
>
--
Philippe.
next prev parent reply other threads:[~2008-04-23 11:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-11 16:09 [Xenomai-help] rt_task_sleep_until question Klaas Gadeyne
2008-04-12 13:11 ` Jan Kiszka
2008-04-12 15:32 ` klaas.gadeyne
2008-04-12 16:01 ` Gilles Chanteperdrix
2008-04-17 15:23 ` Klaas Gadeyne
2008-04-17 15:30 ` Gilles Chanteperdrix
2008-04-17 15:46 ` Gilles Chanteperdrix
2008-04-17 16:07 ` Philippe Gerum
2008-04-17 16:39 ` Gilles Chanteperdrix
2008-04-22 13:45 ` Klaas Gadeyne
2008-04-22 13:49 ` Philippe Gerum
2008-04-22 14:25 ` Klaas Gadeyne
2008-04-22 20:56 ` Philippe Gerum
2008-04-23 11:27 ` Klaas Gadeyne
2008-04-23 11:37 ` Philippe Gerum [this message]
2008-04-23 12:53 ` Bosko Radivojevic
2008-04-23 17:43 ` Philippe Gerum
2008-08-01 23:07 ` [Xenomai-help] Recurring Interrupts Henry Bausley
2008-08-02 7:38 ` Philippe Gerum
2008-08-02 12:24 ` Philippe Gerum
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=480F1F91.7040502@domain.hid \
--to=rpm@xenomai.org \
--cc=jan.kiszka@domain.hid \
--cc=klaas.gadeyne@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.