1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Scheduler Simple Ready Queue Enqueue First |
---|
5 | * @ingroup ScoreScheduler |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 2011. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/chain.h> |
---|
23 | #include <rtems/score/thread.h> |
---|
24 | #include <rtems/score/schedulersimple.h> |
---|
25 | |
---|
26 | void _Scheduler_simple_Ready_queue_enqueue_first( |
---|
27 | Thread_Control *the_thread |
---|
28 | ) |
---|
29 | { |
---|
30 | Chain_Control *ready; |
---|
31 | Chain_Node *the_node; |
---|
32 | Thread_Control *current; |
---|
33 | |
---|
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 ); |
---|
55 | } |
---|