This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling cyg_alarm_delete() from Alarm handler function broken?


Jason Gaiser <JasonG@mail.systech.com> writes:

> Hello!
> 
> There appears to be a bug in the ecos Alarm code when using
> CYGIMP_KERNEL_COUNTERS_SORT_LIST.  According to the documentation,
> cyg_alarm_delete() is callable from DSR context.  Therefore its implied that
> it is safe to call from an alarm handler routine.  However, the
> Cyg_Counter::tick() function moves alarm_list to a temporary location when
> scanning the list for expired timers.  If the alarm handler, called from
> within tick(), tries to delete a timer with cyg_alarm_delete(), the list may
> be left in an inconsistent state.  I first noticed this when a timer I
> deleted from another timer's handler function came back from the dead and
> triggered its handler.  I took a quick peek down in the timer code and
> couldn't find the cause of my problem, but I think they may be related.

Yes, you're right. If the alarm function for one alarm tries to
disable or delete another alarm that happens to be on the same list,
then it won't find it, because the alarm has been moved to a temporary
list for processing. The current code could end up corrupting one of
the temporary lists.

Of course, the whole idea of using the temporary lists was to avoid
any problems with the alarm list changing under the feet of the tick()
routine. I was mainly concerned with new alarms being added, and
completely overlooked the problem of alarms being removed.

Hmmm, there isn't a trivial fix to this. I'll have to think about it
for a bit.


-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]