From: Philippe Gerum <rpm@xenomai.org>
To: Matthias Schneider <ma30002000@yahoo.de>,
"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] FreeRTOS skin
Date: Tue, 06 May 2014 09:46:10 +0200 [thread overview]
Message-ID: <53689342.2050005@xenomai.org> (raw)
In-Reply-To: <1399360194.79292.YahooMailNeo@web171603.mail.ir2.yahoo.com>
On 05/06/2014 09:09 AM, Matthias Schneider wrote:
> ----- Original Message -----
>> From: Philippe Gerum <rpm@xenomai.org>
>> To: Matthias Schneider <ma30002000@yahoo.de>; "xenomai@xenomai.org" <xenomai@xenomai.org>
>> Cc:
>> Sent: Monday, May 5, 2014 3:37 PM
>> Subject: Re: [Xenomai] FreeRTOS skin
>>
>> On 05/05/2014 12:33 PM, Philippe Gerum wrote:
>>> On 05/04/2014 06:59 PM, Matthias Schneider wrote:
>>>> Hi all,
>>>>
>>>> please find enclosed a patch with a FreeRTOS skin for xenomai-forge I
>>>> have
>>>> been working on for some time. I would like to get some feedback and
>>>> advice
>>>> what still needs to be done to get it accepted in Xenomai. There is a
>>>> set of
>>>> unit tests included and the possibility to download the original
>>>> FreeRTOS package
>>>> in order to run most of its (platform independent) test suite. Until
>>>> now I have
>>>> been working under mercury only. Documentation is available in form of
>>>> a README
>>>> file in lib/freertos/README, which should also be a good starting
>> point.
>>>
>>> Ok, thanks for this. Let's address issues gradually, starting with the
>>> task module.
>>>
>>
>> In addition to the above, there are a few coding style items:
>>
>> - Please always take the fastest possible path when exiting on error,
>> so that we don't have to cripple the normal processing following the
>> failure point with error-specific checks. e.g. what is done with the
>> "task" variable in vTaskStartScheduler(), within the thread
>> cancellation loop, ends up being convoluted and confusing, compared
>> to unwinding and leaving the routine immediately after the error is
>> detected.
>
>
> I will review the code and simplify occurrences of the mentioned pattern.
> However I do not see this pattern in this particular code fragment, since it basically does the following:
>
> * take the first entry of the task list
The first check for list emptiness looks racy, as it is not covered by
the scheduler.lock.
> * check if the task object can be locked
> * unlock the scheduler lock
> * if it was possible to lock the task, cancel it
> * else wait 1ms and try to lock it again
If you found it in your task queue but can't lock it, then call Houston
because we have a problem: the task finalizer where this task is dropped
from the list runs prior to deleting the lock. However, testing for the
magic word on success is indeed required in the current implementation,
since the thread lock is dropped shortly prior to canceling the thread
in copperplate.
You could use pvlist_for_each_entry_safe() for iterating over the task
queue.
>
> No error condition leads to leaving this loop. I do agree however, that the
> code is convoluted, mainly due to the erroneous-looking nested locks, one
> for protecting freertos_task_list and one locking the threadobj. The list should be locked while accessing it, while holding it when cancelling the threadobj will lead to deadlocks (task_finalizer takes freertos_scheduler.lock).
>
Setting task to NULL upon locking error, only for the purpose of
avoiding the magic check in the normal code flow is the issue I mentioned:
if (task && threadobj_lock(&task->thobj) == -EINVAL)
task = NULL;
if (task && threadobj_get_magic(&task->thobj) != task_magic) {
threadobj_unlock(&task->thobj);
task = NULL;
}
>
>> - (void)function_call() is useless visual pollution and tells nothing
>> about the only thing that matters to the reader: were you right in
>> omitting the check? Instead, tagging the called routine with the
>> ((warn_unused_result)) attribute when problems may likely arise from
>> not checking the return value, seems a better way to detect
>> potential bugs at build time, which would cause the (void) cast to
>> be ignored when checking the call sites anyway.
> Removed the casts.
>
Thanks, I'll add some warn_unused_result tags to some routines from the
copperplate layer. syncobj_wait* services come to mind, since these may
return -EIDRM or -EINTR, which are situations which have to influence
the code flow when received.
--
Philippe.
next prev parent reply other threads:[~2014-05-06 7:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-04 16:59 [Xenomai] FreeRTOS skin Matthias Schneider
2014-05-04 18:42 ` Gilles Chanteperdrix
2014-05-04 21:22 ` Matthias Schneider
2014-05-05 7:24 ` Philippe Gerum
2014-05-17 14:40 ` Matthias Schneider
2014-05-05 10:33 ` Philippe Gerum
2014-05-05 13:37 ` Philippe Gerum
2014-05-06 7:09 ` Matthias Schneider
2014-05-06 7:46 ` Philippe Gerum [this message]
2014-05-06 7:54 ` Philippe Gerum
2014-05-06 16:50 ` Matthias Schneider
2014-05-17 14:56 ` Matthias Schneider
2014-05-05 14:03 ` Gilles Chanteperdrix
2014-05-05 14:13 ` Philippe Gerum
2014-05-06 17:19 ` Matthias Schneider
2014-05-06 17:47 ` Philippe Gerum
2014-05-06 19:46 ` Matthias Schneider
2014-05-18 18:30 ` Matthias Schneider
2014-05-19 7:46 ` Philippe Gerum
2014-05-20 7:06 ` Matthias Schneider
2014-05-20 7:53 ` 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=53689342.2050005@xenomai.org \
--to=rpm@xenomai.org \
--cc=ma30002000@yahoo.de \
--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.