Skip to contentSkip to conversation

Bottom half task scheduling

Xenomai-help Travis Stratman 3 participants 7 messages Sep 11, 2010 – Sep 12, 2010

lore
Share & tools
lore
#0 lore raw

Hello,

I am writing a Xenomai driver with an interrupt that must trigger a complex series of hardware accesses that may not be atomic (i.e. waiting for DMA to complete). I'd like to move this section to a bottom half. In a Linux driver I would use a workqueue but I haven't been able to determine what the preferred method would be in Xenomai. All of the task creation API that I have considered cannot be called from an interrupt handler as they may reschedule.

Can anyone point me to some documentation or example that covers this? Any pointers would be appreciated.

Thanks,

TAS

#1 lore raw
Quoted 10 lines · Travis Stratman

Hello,

I am writing a Xenomai driver with an interrupt that must trigger a complex series of hardware accesses that may not be atomic (i.e. waiting for DMA to complete). I'd like to move this section to a bottom half. In a Linux driver I would use a workqueue but I haven't been able to determine what the preferred method would be in Xenomai. All of the task creation API that I have considered cannot be called from an interrupt handler as they may reschedule.

Quoted 2 lines

Can anyone point me to some documentation or example that covers this? Any pointers would be appreciated.

You can use a kernel thread, created with rtdm_task_init:
http://www.xenomai.org/documentation/xenomai-2.5/html/api/group__rtdmtask.html#g44b0701b6c28fa8035711f800fdcd371

Signature · 1 line
                                                                Gilles.
#3 lore raw
In reply to Travis Stratman
Quoted 9 lines · Travis Stratman

Hello,

I am writing a Xenomai driver with an interrupt that must trigger a complex series of hardware accesses that may not be atomic (i.e. waiting for DMA to complete). I'd like to move this section to a bottom half. In a Linux driver I would use a workqueue but I haven't been able to determine what the preferred method would be in Xenomai. All of the task creation API that I have considered cannot be called from an interrupt handler as they may reschedule.

Simply create the RTDM task(s) in advance. Creating tasks on demand and in IRQ context would be crazy.

At this chance, also start thinking about what priorities you want to assign to them (typically the harder part of the design).

Quoted 3 lines

Can anyone point me to some documentation or example that covers this? Any pointers would be appreciated.

RTnet uses RTDM tasks quite heavily. But its code base is large, and not all usages are really good examples anymore.

Jan

#4 lore raw
Quoted 3 lines

Simply create the RTDM task(s) in advance. Creating tasks on demand and in IRQ context would be crazy.

This is what I have confusion about. After creating a non-cyclic task with rtdm_task_init(), how do I restart the task in the interrupt handler? Is there a way to do this using rtdm_task_set_period() or some other task function or do I need to have the task wait on an event and wake it back up by signaling the event from the ISR?

Quoted 10 lines

At this chance, also start thinking about what priorities you want to assign to them (typically the harder part of the design).

Quoted 3 lines

Can anyone point me to some documentation or example that covers this? Any pointers would be appreciated.

RTnet uses RTDM tasks quite heavily. But its code base is large, and not all usages are really good examples anymore.

Thanks, I will take a look at the RTnet source with that in mind.

Quoted 4 lines

Jan

Thanks,

TAS

#5 lore raw
Quoted 8 lines · Travis Stratman
Quoted 3 lines

Simply create the RTDM task(s) in advance. Creating tasks on demand and in IRQ context would be crazy.

This is what I have confusion about. After creating a non-cyclic task with rtdm_task_init(), how do I restart the task in the interrupt handler? Is there a way to do this using rtdm_task_set_period() or some other task function or do I need to have the task wait on an event and wake it back up by signaling the event from the ISR?

The latter is the pattern you are looking for. Just loop over rtdm_event_event and the work it has to perform on wakeup.

Jan

#6 lore raw
Quoted 7 lines

The latter is the pattern you are looking for. Just loop over rtdm_event_event and the work it has to perform on wakeup.

Jan

Thanks Jan.

TAS