[rtems commit] rtems: Improve rtems_interrupt_server_create()

Sebastian Huber sebh at rtems.org
Wed Nov 25 07:33:21 UTC 2020


Module:    rtems
Branch:    5
Commit:    dedc3e1d49eaf5b4f5a9180c075ad5793532c52f
Changeset: http://git.rtems.org/rtems/commit/?id=dedc3e1d49eaf5b4f5a9180c075ad5793532c52f

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Nov 23 16:34:26 2020 +0100

rtems: Improve rtems_interrupt_server_create()

Also start interrupt server tasks on processors which do not have a
scheduler.  Applications may dynamically manage processors using
rtems_scheduler_remove_processor() and rtems_scheduler_add_processor().

Close #4190.

---

 bsps/shared/irq/irq-server.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/bsps/shared/irq/irq-server.c b/bsps/shared/irq/irq-server.c
index 19d03dc..2c8df49 100644
--- a/bsps/shared/irq/irq-server.c
+++ b/bsps/shared/irq/irq-server.c
@@ -506,9 +506,6 @@ static rtems_status_code bsp_interrupt_server_create(
   cpu_set_t cpu;
 #endif
 
-  rtems_interrupt_lock_initialize(&s->lock, "Interrupt Server");
-  rtems_chain_initialize_empty(&s->entries);
-
   sc = rtems_task_create(
     rtems_build_name('I', 'R', 'Q', 'S'),
     priority,
@@ -518,23 +515,30 @@ static rtems_status_code bsp_interrupt_server_create(
     &s->server
   );
   if (sc != RTEMS_SUCCESSFUL) {
+    (*s->destroy)(s);
     return sc;
   }
 
+  rtems_interrupt_lock_initialize(&s->lock, "Interrupt Server");
+  rtems_chain_initialize_empty(&s->entries);
+
 #if defined(RTEMS_SMP)
   sc = rtems_scheduler_ident_by_processor(cpu_index, &scheduler);
-  if (sc != RTEMS_SUCCESSFUL) {
-    /* Do not start an interrupt server on a processor without a scheduler */
-    return RTEMS_SUCCESSFUL;
-  }
 
-  sc = rtems_task_set_scheduler(s->server, scheduler, priority);
-  _Assert(sc == RTEMS_SUCCESSFUL);
+  /*
+   * If a scheduler exists for the processor, then move it to this scheduler
+   * and try to set the affinity to the processor, otherwise keep the scheduler
+   * of the executing thread.
+   */
+  if (sc == RTEMS_SUCCESSFUL) {
+    sc = rtems_task_set_scheduler(s->server, scheduler, priority);
+    _Assert(sc == RTEMS_SUCCESSFUL);
 
-  /* Set the task to processor affinity on a best-effort basis */
-  CPU_ZERO(&cpu);
-  CPU_SET(cpu_index, &cpu);
-  (void) rtems_task_set_affinity(s->server, sizeof(cpu), &cpu);
+    /* Set the task to processor affinity on a best-effort basis */
+    CPU_ZERO(&cpu);
+    CPU_SET(cpu_index, &cpu);
+    (void) rtems_task_set_affinity(s->server, sizeof(cpu), &cpu);
+  }
 #else
   (void) cpu_index;
 #endif



More information about the vc mailing list