Changeset 9e7fa07 in rtems


Ignore:
Timestamp:
Oct 31, 2016, 3:23:13 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
47d2464
Parents:
0dd49d0
git-author:
Sebastian Huber <sebastian.huber@…> (10/31/16 15:23:13)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/03/16 10:19:34)
Message:

score: Relax _Scheduler_Set() restrictions

No longer unconditionally prevent scheduler changes if the thread owns
resources. Prevent a scheduler change only in case other threads wait
for the resource.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r0dd49d0 r9e7fa07  
    12151215  Scheduler_Node *old_scheduler_node;
    12161216
    1217   if (
    1218     _Thread_Owns_resources( the_thread )
    1219       || the_thread->Wait.queue != NULL
    1220   ) {
     1217  if ( the_thread->Wait.queue != NULL ) {
    12211218    return STATUS_RESOURCE_IN_USE;
    12221219  }
     
    12381235
    12391236#if defined(RTEMS_SMP)
     1237  if ( !_Chain_Has_only_one_node( &the_thread->Scheduler.Wait_nodes ) ) {
     1238    return STATUS_RESOURCE_IN_USE;
     1239  }
     1240
    12401241  _Thread_Scheduler_process_requests( the_thread );
    12411242  new_scheduler_node = _Thread_Scheduler_get_node_by_index(
  • testsuites/smptests/smpscheduler02/init.c

    r0dd49d0 r9e7fa07  
    2626const char rtems_test_name[] = "SMPSCHEDULER 2";
    2727
    28 #if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
    29 
    3028#define SCHED_A rtems_build_name(' ', ' ', ' ', 'A')
    3129
     
    3634static rtems_id main_task_id;
    3735
    38 static rtems_id sema_id;
     36static rtems_id cmtx_id;
     37
     38static rtems_id imtx_id;
    3939
    4040static void task(rtems_task_argument arg)
     
    4848  rtems_test_assert(sched_get_priority_max(SCHED_RR) == 126);
    4949
    50   sc = rtems_semaphore_obtain(sema_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     50  sc = rtems_semaphore_obtain(cmtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    5151  rtems_test_assert(sc == RTEMS_NOT_DEFINED);
     52
     53  sc = rtems_event_transient_send(main_task_id);
     54  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     55
     56  sc = rtems_semaphore_obtain(imtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     57  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     58
     59  sc = rtems_semaphore_release(imtx_id);
     60  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    5261
    5362  sc = rtems_event_transient_send(main_task_id);
     
    103112
    104113  sc = rtems_semaphore_create(
    105     SCHED_A,
     114    rtems_build_name('C', 'M', 'T', 'X'),
    106115    1,
    107116    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING,
    108117    1,
    109     &sema_id
     118    &cmtx_id
    110119  );
    111120  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    112121
     122  sc = rtems_semaphore_create(
     123    rtems_build_name('I', 'M', 'T', 'X'),
     124    1,
     125    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
     126    1,
     127    &imtx_id
     128  );
     129  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     130
    113131  prio = 2;
    114   sc = rtems_semaphore_set_priority(sema_id, scheduler_a_id, prio, &prio);
     132  sc = rtems_semaphore_set_priority(cmtx_id, scheduler_a_id, prio, &prio);
    115133  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    116134  rtems_test_assert(prio == 1);
     
    118136  if (cpu_count > 1) {
    119137    prio = 1;
    120     sc = rtems_semaphore_set_priority(sema_id, scheduler_b_id, prio, &prio);
     138    sc = rtems_semaphore_set_priority(cmtx_id, scheduler_b_id, prio, &prio);
    121139    rtems_test_assert(sc == RTEMS_NOT_DEFINED);
    122140    rtems_test_assert(prio == 2);
     
    198216    rtems_test_assert(scheduler_id == scheduler_b_id);
    199217
     218    sc = rtems_semaphore_obtain(imtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     219    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     220
    200221    sc = rtems_task_start(task_id, task, 0);
    201222    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     
    206227    sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    207228    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     229
     230    sc = rtems_task_set_scheduler(RTEMS_SELF, scheduler_b_id, 1);
     231    rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     232
     233    sc = rtems_semaphore_release(imtx_id);
     234    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     235
     236    sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     237    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    208238  }
    209239
     
    211241  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    212242
    213   sc = rtems_semaphore_delete(sema_id);
     243  sc = rtems_semaphore_delete(cmtx_id);
     244  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     245
     246  sc = rtems_semaphore_delete(imtx_id);
    214247  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    215248}
    216 
    217 #else /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
    218 
    219 static void test(void)
    220 {
    221   /* Nothing to do */
    222 }
    223 
    224 #endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
    225249
    226250static void Init(rtems_task_argument arg)
     
    244268
    245269#define CONFIGURE_MAXIMUM_TASKS 2
    246 #define CONFIGURE_MAXIMUM_SEMAPHORES 1
     270#define CONFIGURE_MAXIMUM_SEMAPHORES 2
    247271
    248272#define CONFIGURE_SMP_APPLICATION
  • testsuites/sptests/spscheduler01/init.c

    r0dd49d0 r9e7fa07  
    237237
    238238  sc = rtems_task_set_scheduler(self_id, scheduler_id, 1);
    239   rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     239  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    240240
    241241  sc = rtems_semaphore_release(mtx_id);
Note: See TracChangeset for help on using the changeset viewer.