RFC: Interrupt Manager Extension changes

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 13 07:55:08 UTC 2009


Till Straumann wrote:
> I like the idea of a facility to let interrupt handlers execute
> from a task context.
> 
> However, IMO it would be far more flexible and useful if there was not
> just one server task (which still could be the default) but if
> when installing the ISR one could optionally request a new/separate
> task (with desired priority etc.).
[...]

Yes, this is indeed more useful.  I added a server identifier, so that you can
install the handlers on a particular server.  Some problems:

Do we want a default server?
How do we initialize the default server?
How do we refer to the default server?

At the moment we have one default server which is identified by RTEMS_ID_NONE.
In case of more than one running server it is implementation dependent which
one is the default server.

A simple implementation may look like:

One task, one counting semaphore and one list for each server.  The interrupt
handler disables the corresponding interrupt vector on the interrupt
controller, adds one item to the list and increments the counting semaphore.
The server continuously decrements the semaphore and fetches one item at a
time.  It processes the item and enables the corresponding interrupt vector on
the interrupt controller afterwards.  If we want so support shared interrupts,
we need also a counter for each vector to count the number of shared server
handlers per vector. This ensures that we only enable the vector if each
handler was processed.

/**
 * @brief Initializes an interrupt server task.
 *
 * The task will have the priority @a priority, the stack size @a stack_size,
 * the modes @a modes and the attributes @a attributes.  The identifier of the
 * server task will be returned in @a server.  Interrupt handlers can be
 * installed on the server with rtems_interrupt_server_handler_install() and
 * removed with rtems_interrupt_server_handler_remove() using this identifier.
 * In case of an interrupt the request will be forwarded to the server.  The
 * handlers are executed within the server context.  If one handler blocks on
 * something this may delay the processing of other handlers.
 *
 * @note This function may block.
 *
 * @return
 * - On success @c RTEMS_SUCCESSFUL shall be returned.
 * - If the @a server pointer is @c NULL @c RTEMS_INVALID_ADDRESS shall be
 *   returned.
 * - Other error states are BSP specific.
 */
rtems_status_code rtems_interrupt_server_initialize(
  rtems_task_priority priority,
  size_t stack_size,
  rtems_mode modes,
  rtems_attribute attributes,
  rtems_id *server
);

/**
 * @brief Installs the interrupt handler routine @a handler for the interrupt
 * vector with number @a vector on the server @a server.
 *
 * The handler routine will be executed on the corresponding interrupt server
 * task.  A server identifier of @c RTEMS_ID_NONE may be used to install the
 * handler on some available server.
 *
 * @note This function may block.
 *
 * @see rtems_interrupt_handler_install().
 *
 * @return
 * - On success @c RTEMS_SUCCESSFUL shall be returned.
 * - If the interrupt handler server is not initialized
 *   @c RTEMS_INCORRECT_STATE shall be returned.
 * - For other errors see rtems_interrupt_handler_install().
 */
rtems_status_code rtems_interrupt_server_handler_install(
  rtems_id server,
  rtems_vector_number vector,
  const char *info,
  rtems_option options,
  rtems_interrupt_handler handler,
  void *arg
);

/**
 * @brief Removes the interrupt handler routine @a handler with argument @a arg
 * for the interrupt vector with number @a vector from the server @a server.
 *
 * @note This function may block.
 *
 * @see rtems_interrupt_handler_remove().
 *
 * @return
 * - On success @c RTEMS_SUCCESSFUL shall be returned.
 * - If the interrupt handler server is not initialized
 *   @c RTEMS_INCORRECT_STATE shall be returned.
 * - For other errors see rtems_interrupt_handler_remove().
 */
rtems_status_code rtems_interrupt_server_handler_remove(
  rtems_id server,
  rtems_vector_number vector,
  rtems_interrupt_handler handler,
  void *arg
);

-- 
Sebastian Huber, Embedded Brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list