Eclectic

About programming and maybe more…

Archive for the ‘eCos’ Category

eCos interrupt handling

Posted by tread on April 30, 2007

or what makes eCos real time.

I’m trying to use Freemind – this is an initial mindmap of my current understanding of eCos internals:

ecos.jpeg

Interrupt handling is critical to real time systems – and quick handling can be disturbed by atomic activities which run with interrupts disabled. To minimize latencies, eCos has a split interrupt handling system:

  • ISR – Interrupt Service Routine
  • DSR – Deferred Service Routine

DSRs can be run with interrupts enabled, and ISRs should complete quickly. DSRs execute later when thread scheduling is allowed – this allows higher priority interrupts to umm, interrupt. This also allows them to interact with the kernel.

ISRs can be coded to:

  • Disable interrupts till DSR is serviced (typical behaviour).
  • Setup counters such that one DSR can service multiple interrupts.

On eCos, thread stack size is defined by CYGNUM_HAL_STACK_SIZE_MINIMUM. Since interrupts are enabled during DSRs, we can have nested interrupts, and this may cause a stack overflow. Hence interrupts have a separate stack, which is large enough to handle some predefined “N” interrupts. Thus each thread needs to hold only one interrupt state, and nested interrupts go on the interrupt stack. Using a separate interrupt stack is configurable, and if not chosen, then the thread stacks have to be larger.

Reference: Redhat eCos reference manual.

Posted in Programming, eCos, embedded | 1 Comment »