Changeset 99c73303 in rtems


Ignore:
Timestamp:
Nov 23, 2020, 3:34:26 PM (2 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b2ea2bc3
Parents:
3c093d6
git-author:
Sebastian Huber <sebastian.huber@…> (11/23/20 15:34:26)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/24/20 06:40:24)
Message:

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().

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bsps/shared/irq/irq-server.c

    r3c093d6 r99c73303  
    507507#endif
    508508
    509   rtems_interrupt_lock_initialize(&s->lock, "Interrupt Server");
    510   rtems_chain_initialize_empty(&s->entries);
    511 
    512509  sc = rtems_task_create(
    513510    rtems_build_name('I', 'R', 'Q', 'S'),
     
    519516  );
    520517  if (sc != RTEMS_SUCCESSFUL) {
    521     return sc;
    522   }
     518    (*s->destroy)(s);
     519    return sc;
     520  }
     521
     522  rtems_interrupt_lock_initialize(&s->lock, "Interrupt Server");
     523  rtems_chain_initialize_empty(&s->entries);
    523524
    524525#if defined(RTEMS_SMP)
    525526  sc = rtems_scheduler_ident_by_processor(cpu_index, &scheduler);
    526   if (sc != RTEMS_SUCCESSFUL) {
    527     /* Do not start an interrupt server on a processor without a scheduler */
    528     return RTEMS_SUCCESSFUL;
    529   }
    530 
    531   sc = rtems_task_set_scheduler(s->server, scheduler, priority);
    532   _Assert(sc == RTEMS_SUCCESSFUL);
    533 
    534   /* Set the task to processor affinity on a best-effort basis */
    535   CPU_ZERO(&cpu);
    536   CPU_SET(cpu_index, &cpu);
    537   (void) rtems_task_set_affinity(s->server, sizeof(cpu), &cpu);
     527
     528  /*
     529   * If a scheduler exists for the processor, then move it to this scheduler
     530   * and try to set the affinity to the processor, otherwise keep the scheduler
     531   * of the executing thread.
     532   */
     533  if (sc == RTEMS_SUCCESSFUL) {
     534    sc = rtems_task_set_scheduler(s->server, scheduler, priority);
     535    _Assert(sc == RTEMS_SUCCESSFUL);
     536
     537    /* Set the task to processor affinity on a best-effort basis */
     538    CPU_ZERO(&cpu);
     539    CPU_SET(cpu_index, &cpu);
     540    (void) rtems_task_set_affinity(s->server, sizeof(cpu), &cpu);
     541  }
    538542#else
    539543  (void) cpu_index;
  • testsuites/smptests/smpirqs01/init.c

    r3c093d6 r99c73303  
    6565}
    6666
    67 T_TEST_CASE(InterruptServerSMPInitializeDestroy)
    68 {
    69   rtems_status_code sc;
    70   uint32_t server_count;
    71   void *greedy;
     67T_TEST_CASE(InterruptServerSMPInitializeIncorrectState)
     68{
     69  rtems_status_code sc;
     70  uint32_t server_count;
    7271
    7372  T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
     
    105104  T_rsc_success(sc);
    106105  ensure_server_termination();
     106}
     107
     108T_TEST_CASE(InterruptServerSMPInitializeInvalidPriority)
     109{
     110  rtems_status_code sc;
     111  uint32_t server_count;
     112
     113  T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
    107114
    108115  server_count = 456;
     
    135142  T_rsc_success(sc);
    136143  ensure_server_termination();
     144}
     145
     146T_TEST_CASE(InterruptServerSMPInitializeNoMemory)
     147{
     148  rtems_status_code sc;
     149  uint32_t server_count;
     150  void *greedy;
     151
     152  T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
    137153
    138154  greedy = rtems_heap_greedy_allocate(NULL, 0);
     
    157173  sc = rtems_interrupt_server_delete(1);
    158174  T_rsc(sc, RTEMS_INVALID_ID);
     175}
     176
     177T_TEST_CASE(InterruptServerSMPInitializeNoScheduler)
     178{
     179  rtems_status_code sc;
     180  uint32_t server_count;
     181  rtems_id scheduler_id;
     182  rtems_task_priority prio;
     183
     184  T_assert_eq_u32(rtems_scheduler_get_processor_maximum(), 2);
     185
     186  scheduler_id = 0;
     187  sc = rtems_scheduler_ident_by_processor(1, &scheduler_id);
     188  T_rsc_success(sc);
     189  T_ne_u32(scheduler_id, 0);
     190
     191  sc = rtems_scheduler_remove_processor(scheduler_id, 1);
     192  T_rsc_success(sc);
     193
     194  server_count = 456;
     195  sc = rtems_interrupt_server_initialize(
     196    123,
     197    RTEMS_MINIMUM_STACK_SIZE,
     198    RTEMS_DEFAULT_MODES,
     199    RTEMS_DEFAULT_ATTRIBUTES,
     200    &server_count
     201  );
     202  T_rsc_success(sc);
     203  T_eq_u32(server_count, 2);
     204
     205  sc = rtems_interrupt_server_delete(0);
     206  T_rsc_success(sc);
     207
     208  sc = rtems_interrupt_server_delete(1);
     209  T_rsc_success(sc);
     210
     211  prio = 0;
     212  sc = rtems_task_set_priority(RTEMS_SELF, 124, &prio);
     213  T_rsc_success(sc);
     214
     215  sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio);
     216  T_rsc_success(sc);
     217
     218  sc = rtems_scheduler_add_processor(scheduler_id, 1);
     219  T_rsc_success(sc);
    159220}
    160221
Note: See TracChangeset for help on using the changeset viewer.