source: rtems/cpukit/score/src/schedulersimplereadyqueueenqueuefirst.c @ d7c3883

4.115
Last change on this file since d7c3883 was 0118ed6, checked in by Joel Sherrill <joel.sherrill@…>, on 03/16/11 at 16:32:22

2011-03-16 Jennifer Averett <jennifer.averett@…>

PR 1743/cpu

  • sapi/include/confdefs.h, score/Makefile.am, score/preinstall.am: Add Simple Priority Scheduler as complement to existing Deterministic Priority Scheduler. This scheduler serves both as an example and as a lighter weight implementation for smaller systems.
  • score/include/rtems/score/schedulersimple.h, score/inline/rtems/score/schedulersimple.inl, score/src/schedulersimple.c, score/src/schedulersimpleblock.c, score/src/schedulersimpleenqueue.c, score/src/schedulersimpleenqueuefirst.c, score/src/schedulersimpleextract.c, score/src/schedulersimplereadyqueueenqueue.c, score/src/schedulersimplereadyqueueenqueuefirst.c, score/src/schedulersimpleschedule.c, score/src/schedulersimpleunblock.c, score/src/schedulersimpleyield.c: New files.
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  Schedule Simple Handler / Ready Queue Enqueue First
3 *
4 *  COPYRIGHT (c) 2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/chain.h>
20#include <rtems/score/thread.h>
21#include <rtems/score/schedulersimple.h>
22
23void _Scheduler_simple_Ready_queue_Enqueue_first(
24  Thread_Control    *the_thread
25)
26{
27  Chain_Control    *ready;
28  Chain_Node       *the_node;
29  Thread_Control   *current;
30
31  ready    = (Chain_Control *)_Scheduler.information;
32  current  = (Thread_Control *)ready;
33
34  /*
35   * Do NOT need to check for end of chain because there is always
36   * at least one task on the ready chain -- the IDLE task.  It can
37   * never block, should never attempt to obtain a semaphore or mutex,
38   * and thus will always be there.
39   */
40  for ( the_node = _Chain_First(ready) ; ; the_node = the_node->next ) {
41    current = (Thread_Control *) the_node;
42
43    /* break when AT HEAD OF (or PAST) our priority */
44    if ( the_thread->current_priority <= current->current_priority ) {
45      current = (Thread_Control *)current->Object.Node.previous;
46      break;
47    }
48  }
49
50  /* enqueue */
51  _Chain_Insert_unprotected( (Chain_Node *)current, &the_thread->Object.Node );
52}
Note: See TracBrowser for help on using the repository browser.