Changeset 8f42092 in rtems


Ignore:
Timestamp:
Jun 12, 2013, 9:39:49 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
a936aa49
Parents:
a344308
git-author:
Sebastian Huber <sebastian.huber@…> (06/12/13 09:39:49)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/14/13 14:26:08)
Message:

scheduler: Simplify simple scheduler

Add and use _Scheduler_simple_Insert_priority_fifo_order(),
_Scheduler_simple_Insert_priority_lifo_order(),
_Scheduler_simple_Insert_priority_fifo() and
_Scheduler_simple_Insert_priority_lifo().

Location:
cpukit/score
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/inline/rtems/score/schedulersimple.inl

    ra344308 r8f42092  
    4949}
    5050
     51RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order(
     52  const Chain_Node *to_insert,
     53  const Chain_Node *next
     54)
     55{
     56  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
     57  const Thread_Control *thread_next = (const Thread_Control *) next;
     58
     59  return thread_to_insert->current_priority <= thread_next->current_priority;
     60}
     61
     62RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order(
     63  const Chain_Node *to_insert,
     64  const Chain_Node *next
     65)
     66{
     67  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
     68  const Thread_Control *thread_next = (const Thread_Control *) next;
     69
     70  return thread_to_insert->current_priority < thread_next->current_priority;
     71}
     72
     73RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo(
     74  Chain_Control *chain,
     75  Thread_Control *to_insert
     76)
     77{
     78  _Chain_Insert_ordered_unprotected(
     79    chain,
     80    &to_insert->Object.Node,
     81    _Scheduler_simple_Insert_priority_lifo_order
     82  );
     83}
     84
     85RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo(
     86  Chain_Control *chain,
     87  Thread_Control *to_insert
     88)
     89{
     90  _Chain_Insert_ordered_unprotected(
     91    chain,
     92    &to_insert->Object.Node,
     93    _Scheduler_simple_Insert_priority_fifo_order
     94  );
     95}
     96
    5197/** @} */
    5298
  • cpukit/score/src/schedulersimplereadyqueueenqueue.c

    ra344308 r8f42092  
    2929)
    3030{
    31   Chain_Control    *ready;
    32   Chain_Node       *the_node;
    33   Thread_Control   *current;
     31  Chain_Control *ready = (Chain_Control *) _Scheduler.information;
    3432
    35   ready    = (Chain_Control *)_Scheduler.information;
    36   the_node = _Chain_First( ready );
    37   current  = (Thread_Control *)ready;
    38 
    39   for ( ; !_Chain_Is_tail( ready, the_node ) ; the_node = the_node->next ) {
    40     current = (Thread_Control *) the_node;
    41 
    42     /* break when AT END OR PAST our priority */
    43     if ( the_thread->current_priority < current->current_priority ) {
    44       current = (Thread_Control *)current->Object.Node.previous;
    45       break;
    46     }
    47   }
    48 
    49   /* enqueue */
    50   _Chain_Insert_unprotected( (Chain_Node *)current, &the_thread->Object.Node );
     33  _Scheduler_simple_Insert_priority_fifo( ready, the_thread );
    5134}
  • cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c

    ra344308 r8f42092  
    2828)
    2929{
    30   Chain_Control    *ready;
    31   Chain_Node       *the_node;
    32   Thread_Control   *current;
     30  Chain_Control *ready = (Chain_Control *) _Scheduler.information;
    3331
    34   ready    = (Chain_Control *)_Scheduler.information;
    35   current  = (Thread_Control *)ready;
    36 
    37   /*
    38    * Do NOT need to check for end of chain because there is always
    39    * at least one task on the ready chain -- the IDLE task.  It can
    40    * never block, should never attempt to obtain a semaphore or mutex,
    41    * and thus will always be there.
    42    */
    43   for ( the_node = _Chain_First(ready) ; ; the_node = the_node->next ) {
    44     current = (Thread_Control *) the_node;
    45 
    46     /* break when AT HEAD OF (or PAST) our priority */
    47     if ( the_thread->current_priority <= current->current_priority ) {
    48       current = (Thread_Control *)current->Object.Node.previous;
    49       break;
    50     }
    51   }
    52 
    53   /* enqueue */
    54   _Chain_Insert_unprotected( (Chain_Node *)current, &the_thread->Object.Node );
     32  _Scheduler_simple_Insert_priority_lifo( ready, the_thread );
    5533}
Note: See TracChangeset for help on using the changeset viewer.