Changeset 05ca53d in rtems for testsuites/smptests


Ignore:
Timestamp:
Oct 31, 2016, 12:08:33 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
58bced6
Parents:
1f5bee3
git-author:
Sebastian Huber <sebastian.huber@…> (10/31/16 12:08:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/10/16 08:22:09)
Message:

rtems: Add scheduler processor add/remove

Update #2797.

Location:
testsuites/smptests
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • testsuites/smptests/Makefile.am

    r1f5bee3 r05ca53d  
    3838SUBDIRS += smpscheduler02
    3939SUBDIRS += smpscheduler03
     40SUBDIRS += smpscheduler04
    4041SUBDIRS += smpschedsem01
    4142SUBDIRS += smpsignal01
  • testsuites/smptests/configure.ac

    r1f5bee3 r05ca53d  
    9898smpscheduler02/Makefile
    9999smpscheduler03/Makefile
     100smpscheduler04/Makefile
    100101smpschedsem01/Makefile
    101102smpsignal01/Makefile
  • testsuites/smptests/smpscheduler02/init.c

    r1f5bee3 r05ca53d  
    3838static rtems_id imtx_id;
    3939
     40static volatile bool ready;
     41
    4042static void task(rtems_task_argument arg)
    4143{
     
    6567  while (1) {
    6668    /* Do nothing */
     69  }
     70}
     71
     72static void sticky_task(rtems_task_argument arg)
     73{
     74  rtems_status_code sc;
     75  rtems_id mtx_id;
     76
     77  (void) arg;
     78
     79  rtems_test_assert(rtems_get_current_processor() == 0);
     80
     81  sc = rtems_semaphore_create(
     82    rtems_build_name(' ', 'M', 'T', 'X'),
     83    1,
     84    RTEMS_BINARY_SEMAPHORE | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING,
     85    2,
     86    &mtx_id
     87  );
     88  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     89
     90  sc = rtems_semaphore_obtain(mtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     91  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     92
     93  ready = true;
     94
     95  sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     96  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     97
     98  sc = rtems_semaphore_release(mtx_id);
     99  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     100
     101  sc = rtems_semaphore_delete(mtx_id);
     102  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     103
     104  sc = rtems_event_transient_send(main_task_id);
     105  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     106
     107  while (1) {
     108    /* Do nothing */
     109  }
     110}
     111
     112static void test_scheduler_add_remove_processors(void)
     113{
     114  rtems_status_code sc;
     115  rtems_id scheduler_a_id;
     116  rtems_id scheduler_c_id;
     117
     118  sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
     119  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     120
     121  sc = rtems_scheduler_ident(SCHED_C, &scheduler_c_id);
     122  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     123
     124  sc = rtems_scheduler_add_processor(scheduler_c_id, 62);
     125  rtems_test_assert(sc == RTEMS_NOT_CONFIGURED);
     126
     127  sc = rtems_scheduler_add_processor(scheduler_c_id, 63);
     128  rtems_test_assert(sc == RTEMS_INCORRECT_STATE);
     129
     130  sc = rtems_scheduler_remove_processor(scheduler_c_id, 62);
     131  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
     132
     133  sc = rtems_scheduler_remove_processor(scheduler_a_id, 0);
     134  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     135
     136  if (rtems_get_processor_count() > 1) {
     137    rtems_id scheduler_b_id;
     138    rtems_id task_id;
     139
     140    sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
     141    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     142
     143    sc = rtems_scheduler_remove_processor(scheduler_b_id, 1);
     144    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     145
     146    sc = rtems_scheduler_add_processor(scheduler_a_id, 1);
     147    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     148
     149    rtems_test_assert(rtems_get_current_processor() == 0);
     150
     151    sc = rtems_scheduler_remove_processor(scheduler_a_id, 0);
     152    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     153
     154    rtems_test_assert(rtems_get_current_processor() == 1);
     155
     156    sc = rtems_scheduler_add_processor(scheduler_a_id, 0);
     157    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     158
     159    rtems_test_assert(rtems_get_current_processor() == 1);
     160
     161    sc = rtems_task_create(
     162      rtems_build_name('T', 'A', 'S', 'K'),
     163      2,
     164      RTEMS_MINIMUM_STACK_SIZE,
     165      RTEMS_DEFAULT_MODES,
     166      RTEMS_DEFAULT_ATTRIBUTES,
     167      &task_id
     168    );
     169    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     170
     171    sc = rtems_task_start(task_id, sticky_task, 0);
     172    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     173
     174    while (!ready) {
     175      /* Wait */
     176    }
     177
     178    sc = rtems_scheduler_remove_processor(scheduler_a_id, 1);
     179    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     180
     181    rtems_test_assert(rtems_get_current_processor() == 0);
     182
     183    sc = rtems_event_transient_send(task_id);
     184    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     185
     186    sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     187    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     188
     189    sc = rtems_task_delete(task_id);
     190    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     191
     192    sc = rtems_scheduler_add_processor(scheduler_b_id, 1);
     193    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    67194  }
    68195}
     
    249376  sc = rtems_semaphore_delete(imtx_id);
    250377  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     378
     379  test_scheduler_add_remove_processors();
    251380}
    252381
     
    272401#define CONFIGURE_MAXIMUM_TASKS 2
    273402#define CONFIGURE_MAXIMUM_SEMAPHORES 2
     403#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
    274404
    275405#define CONFIGURE_SMP_APPLICATION
Note: See TracChangeset for help on using the changeset viewer.