source: rtems/cpukit/score/include/rtems/score/schedulersimpleimpl.h @ 2369b10

4.115
Last change on this file since 2369b10 was 2369b10, checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/14 at 14:04:10

score: Add and use _Scheduler_Get_context()

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the Manipulation of the
5 * Priority-Based Scheduling Structures
6 *
7 * This inline file contains all of the inlined routines associated with
8 * the manipulation of the priority-based scheduling structures.
9 */
10
11/*
12 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H
20#define _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H
21
22#include <rtems/score/schedulersimple.h>
23#include <rtems/score/chainimpl.h>
24#include <rtems/score/schedulerimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @addtogroup ScoreSchedulerSimple
32 */
33/**@{**/
34
35RTEMS_INLINE_ROUTINE Scheduler_simple_Context *
36  _Scheduler_simple_Get_context( const Scheduler_Control *scheduler )
37{
38  return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler );
39}
40
41/**
42 * This routine puts @a the_thread on to the ready queue.
43 *
44 * @param[in] the_ready_queue is a pointer to the ready queue head
45 * @param[in] the_thread is the thread to be blocked
46 */
47RTEMS_INLINE_ROUTINE void _Scheduler_simple_Ready_queue_requeue(
48  const Scheduler_Control *scheduler,
49  Thread_Control          *the_thread
50)
51{
52  /* extract */
53  _Chain_Extract_unprotected( &the_thread->Object.Node );
54
55  /* enqueue */
56  _Scheduler_simple_Ready_queue_enqueue( scheduler, the_thread );
57}
58
59RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order(
60  const Chain_Node *to_insert,
61  const Chain_Node *next
62)
63{
64  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
65  const Thread_Control *thread_next = (const Thread_Control *) next;
66
67  return thread_to_insert->current_priority <= thread_next->current_priority;
68}
69
70RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order(
71  const Chain_Node *to_insert,
72  const Chain_Node *next
73)
74{
75  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
76  const Thread_Control *thread_next = (const Thread_Control *) next;
77
78  return thread_to_insert->current_priority < thread_next->current_priority;
79}
80
81RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo(
82  Chain_Control *chain,
83  Thread_Control *to_insert
84)
85{
86  _Chain_Insert_ordered_unprotected(
87    chain,
88    &to_insert->Object.Node,
89    _Scheduler_simple_Insert_priority_lifo_order
90  );
91}
92
93RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo(
94  Chain_Control *chain,
95  Thread_Control *to_insert
96)
97{
98  _Chain_Insert_ordered_unprotected(
99    chain,
100    &to_insert->Object.Node,
101    _Scheduler_simple_Insert_priority_fifo_order
102  );
103}
104
105RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body(
106  const Scheduler_Control *scheduler,
107  Thread_Control          *the_thread,
108  bool                     force_dispatch
109)
110{
111  Scheduler_simple_Context *context =
112    _Scheduler_simple_Get_context( scheduler );
113  Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready );
114
115  ( void ) the_thread;
116
117  _Scheduler_Update_heir( heir, force_dispatch );
118}
119
120/** @} */
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
127/* end of include file */
Note: See TracBrowser for help on using the repository browser.