skeleton for lab1

Dependencies:   AvailableMemory mbed-rtos mbed

Fork of helloaabbc by 32314 mbed

Committer:
mbed36372
Date:
Fri Apr 04 21:31:22 2014 +0000
Revision:
1:55e99f6e2aa5
Parent:
0:1c8f2727e9f5
SP14_lab1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
y7jin 0:1c8f2727e9f5 1 /*----------------------------------------------------------------------------
y7jin 0:1c8f2727e9f5 2 * RL-ARM - RTX
y7jin 0:1c8f2727e9f5 3 *----------------------------------------------------------------------------
y7jin 0:1c8f2727e9f5 4 * Name: RT_LIST.C
y7jin 0:1c8f2727e9f5 5 * Purpose: Functions for the management of different lists
y7jin 0:1c8f2727e9f5 6 * Rev.: V4.60
y7jin 0:1c8f2727e9f5 7 *----------------------------------------------------------------------------
y7jin 0:1c8f2727e9f5 8 *
y7jin 0:1c8f2727e9f5 9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
y7jin 0:1c8f2727e9f5 10 * All rights reserved.
y7jin 0:1c8f2727e9f5 11 * Redistribution and use in source and binary forms, with or without
y7jin 0:1c8f2727e9f5 12 * modification, are permitted provided that the following conditions are met:
y7jin 0:1c8f2727e9f5 13 * - Redistributions of source code must retain the above copyright
y7jin 0:1c8f2727e9f5 14 * notice, this list of conditions and the following disclaimer.
y7jin 0:1c8f2727e9f5 15 * - Redistributions in binary form must reproduce the above copyright
y7jin 0:1c8f2727e9f5 16 * notice, this list of conditions and the following disclaimer in the
y7jin 0:1c8f2727e9f5 17 * documentation and/or other materials provided with the distribution.
y7jin 0:1c8f2727e9f5 18 * - Neither the name of ARM nor the names of its contributors may be used
y7jin 0:1c8f2727e9f5 19 * to endorse or promote products derived from this software without
y7jin 0:1c8f2727e9f5 20 * specific prior written permission.
y7jin 0:1c8f2727e9f5 21 *
y7jin 0:1c8f2727e9f5 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
y7jin 0:1c8f2727e9f5 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
y7jin 0:1c8f2727e9f5 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
y7jin 0:1c8f2727e9f5 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
y7jin 0:1c8f2727e9f5 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
y7jin 0:1c8f2727e9f5 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
y7jin 0:1c8f2727e9f5 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
y7jin 0:1c8f2727e9f5 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
y7jin 0:1c8f2727e9f5 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
y7jin 0:1c8f2727e9f5 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
y7jin 0:1c8f2727e9f5 32 * POSSIBILITY OF SUCH DAMAGE.
y7jin 0:1c8f2727e9f5 33 *---------------------------------------------------------------------------*/
y7jin 0:1c8f2727e9f5 34
y7jin 0:1c8f2727e9f5 35 #include "rt_TypeDef.h"
y7jin 0:1c8f2727e9f5 36 #include "RTX_Config.h"
y7jin 0:1c8f2727e9f5 37 #include "rt_System.h"
y7jin 0:1c8f2727e9f5 38 #include "rt_List.h"
y7jin 0:1c8f2727e9f5 39 #include "rt_Task.h"
y7jin 0:1c8f2727e9f5 40 #include "rt_Time.h"
y7jin 0:1c8f2727e9f5 41 #include "rt_HAL_CM.h"
y7jin 0:1c8f2727e9f5 42
y7jin 0:1c8f2727e9f5 43 /*----------------------------------------------------------------------------
y7jin 0:1c8f2727e9f5 44 * Global Variables
y7jin 0:1c8f2727e9f5 45 *---------------------------------------------------------------------------*/
y7jin 0:1c8f2727e9f5 46
y7jin 0:1c8f2727e9f5 47 /* List head of chained ready tasks */
y7jin 0:1c8f2727e9f5 48 struct OS_XCB os_rdy;
y7jin 0:1c8f2727e9f5 49 /* List head of chained delay tasks */
y7jin 0:1c8f2727e9f5 50 struct OS_XCB os_dly;
y7jin 0:1c8f2727e9f5 51
y7jin 0:1c8f2727e9f5 52
y7jin 0:1c8f2727e9f5 53 /*----------------------------------------------------------------------------
y7jin 0:1c8f2727e9f5 54 * Functions
y7jin 0:1c8f2727e9f5 55 *---------------------------------------------------------------------------*/
y7jin 0:1c8f2727e9f5 56
y7jin 0:1c8f2727e9f5 57
y7jin 0:1c8f2727e9f5 58 /*--------------------------- rt_put_prio -----------------------------------*/
y7jin 0:1c8f2727e9f5 59
y7jin 0:1c8f2727e9f5 60 void rt_put_prio (P_XCB p_CB, P_TCB p_task) {
y7jin 0:1c8f2727e9f5 61 /* Put task identified with "p_task" into list ordered by priority. */
y7jin 0:1c8f2727e9f5 62 /* "p_CB" points to head of list; list has always an element at end with */
y7jin 0:1c8f2727e9f5 63 /* a priority less than "p_task->prio". */
y7jin 0:1c8f2727e9f5 64 P_TCB p_CB2;
y7jin 0:1c8f2727e9f5 65 U32 prio;
y7jin 0:1c8f2727e9f5 66 BOOL sem_mbx = __FALSE;
y7jin 0:1c8f2727e9f5 67
y7jin 0:1c8f2727e9f5 68 if (p_CB->cb_type == SCB || p_CB->cb_type == MCB || p_CB->cb_type == MUCB) {
y7jin 0:1c8f2727e9f5 69 sem_mbx = __TRUE;
y7jin 0:1c8f2727e9f5 70 }
y7jin 0:1c8f2727e9f5 71 prio = p_task->prio;
y7jin 0:1c8f2727e9f5 72 p_CB2 = p_CB->p_lnk;
y7jin 0:1c8f2727e9f5 73 /* Search for an entry in the list */
y7jin 0:1c8f2727e9f5 74 while (p_CB2 != NULL && prio <= p_CB2->prio) {
y7jin 0:1c8f2727e9f5 75 p_CB = (P_XCB)p_CB2;
y7jin 0:1c8f2727e9f5 76 p_CB2 = p_CB2->p_lnk;
y7jin 0:1c8f2727e9f5 77 }
y7jin 0:1c8f2727e9f5 78 /* Entry found, insert the task into the list */
y7jin 0:1c8f2727e9f5 79 p_task->p_lnk = p_CB2;
y7jin 0:1c8f2727e9f5 80 p_CB->p_lnk = p_task;
y7jin 0:1c8f2727e9f5 81 if (sem_mbx) {
y7jin 0:1c8f2727e9f5 82 if (p_CB2 != NULL) {
y7jin 0:1c8f2727e9f5 83 p_CB2->p_rlnk = p_task;
y7jin 0:1c8f2727e9f5 84 }
y7jin 0:1c8f2727e9f5 85 p_task->p_rlnk = (P_TCB)p_CB;
y7jin 0:1c8f2727e9f5 86 }
y7jin 0:1c8f2727e9f5 87 else {
y7jin 0:1c8f2727e9f5 88 p_task->p_rlnk = NULL;
y7jin 0:1c8f2727e9f5 89 }
y7jin 0:1c8f2727e9f5 90 }
y7jin 0:1c8f2727e9f5 91
y7jin 0:1c8f2727e9f5 92
y7jin 0:1c8f2727e9f5 93 /*--------------------------- rt_get_first ----------------------------------*/
y7jin 0:1c8f2727e9f5 94
y7jin 0:1c8f2727e9f5 95 P_TCB rt_get_first (P_XCB p_CB) {
y7jin 0:1c8f2727e9f5 96 /* Get task at head of list: it is the task with highest priority. */
y7jin 0:1c8f2727e9f5 97 /* "p_CB" points to head of list. */
y7jin 0:1c8f2727e9f5 98 P_TCB p_first;
y7jin 0:1c8f2727e9f5 99
y7jin 0:1c8f2727e9f5 100 p_first = p_CB->p_lnk;
y7jin 0:1c8f2727e9f5 101 p_CB->p_lnk = p_first->p_lnk;
y7jin 0:1c8f2727e9f5 102 if (p_CB->cb_type == SCB || p_CB->cb_type == MCB || p_CB->cb_type == MUCB) {
y7jin 0:1c8f2727e9f5 103 if (p_first->p_lnk != NULL) {
y7jin 0:1c8f2727e9f5 104 p_first->p_lnk->p_rlnk = (P_TCB)p_CB;
y7jin 0:1c8f2727e9f5 105 p_first->p_lnk = NULL;
y7jin 0:1c8f2727e9f5 106 }
y7jin 0:1c8f2727e9f5 107 p_first->p_rlnk = NULL;
y7jin 0:1c8f2727e9f5 108 }
y7jin 0:1c8f2727e9f5 109 else {
y7jin 0:1c8f2727e9f5 110 p_first->p_lnk = NULL;
y7jin 0:1c8f2727e9f5 111 }
y7jin 0:1c8f2727e9f5 112 return (p_first);
y7jin 0:1c8f2727e9f5 113 }
y7jin 0:1c8f2727e9f5 114
y7jin 0:1c8f2727e9f5 115
y7jin 0:1c8f2727e9f5 116 /*--------------------------- rt_put_rdy_first ------------------------------*/
y7jin 0:1c8f2727e9f5 117
y7jin 0:1c8f2727e9f5 118 void rt_put_rdy_first (P_TCB p_task) {
y7jin 0:1c8f2727e9f5 119 /* Put task identified with "p_task" at the head of the ready list. The */
y7jin 0:1c8f2727e9f5 120 /* task must have at least a priority equal to highest priority in list. */
y7jin 0:1c8f2727e9f5 121 p_task->p_lnk = os_rdy.p_lnk;
y7jin 0:1c8f2727e9f5 122 p_task->p_rlnk = NULL;
y7jin 0:1c8f2727e9f5 123 os_rdy.p_lnk = p_task;
y7jin 0:1c8f2727e9f5 124 }
y7jin 0:1c8f2727e9f5 125
y7jin 0:1c8f2727e9f5 126
y7jin 0:1c8f2727e9f5 127 /*--------------------------- rt_get_same_rdy_prio --------------------------*/
y7jin 0:1c8f2727e9f5 128
y7jin 0:1c8f2727e9f5 129 P_TCB rt_get_same_rdy_prio (void) {
y7jin 0:1c8f2727e9f5 130 /* Remove a task of same priority from ready list if any exists. Other- */
y7jin 0:1c8f2727e9f5 131 /* wise return NULL. */
y7jin 0:1c8f2727e9f5 132 P_TCB p_first;
y7jin 0:1c8f2727e9f5 133
y7jin 0:1c8f2727e9f5 134 p_first = os_rdy.p_lnk;
y7jin 0:1c8f2727e9f5 135 if (p_first->prio == os_tsk.run->prio) {
y7jin 0:1c8f2727e9f5 136 os_rdy.p_lnk = os_rdy.p_lnk->p_lnk;
y7jin 0:1c8f2727e9f5 137 return (p_first);
y7jin 0:1c8f2727e9f5 138 }
y7jin 0:1c8f2727e9f5 139 return (NULL);
y7jin 0:1c8f2727e9f5 140 }
y7jin 0:1c8f2727e9f5 141
y7jin 0:1c8f2727e9f5 142
y7jin 0:1c8f2727e9f5 143 /*--------------------------- rt_resort_prio --------------------------------*/
y7jin 0:1c8f2727e9f5 144
y7jin 0:1c8f2727e9f5 145 void rt_resort_prio (P_TCB p_task) {
y7jin 0:1c8f2727e9f5 146 /* Re-sort ordered lists after the priority of 'p_task' has changed. */
y7jin 0:1c8f2727e9f5 147 P_TCB p_CB;
y7jin 0:1c8f2727e9f5 148
y7jin 0:1c8f2727e9f5 149 if (p_task->p_rlnk == NULL) {
y7jin 0:1c8f2727e9f5 150 if (p_task->state == READY) {
y7jin 0:1c8f2727e9f5 151 /* Task is chained into READY list. */
y7jin 0:1c8f2727e9f5 152 p_CB = (P_TCB)&os_rdy;
y7jin 0:1c8f2727e9f5 153 goto res;
y7jin 0:1c8f2727e9f5 154 }
y7jin 0:1c8f2727e9f5 155 }
y7jin 0:1c8f2727e9f5 156 else {
y7jin 0:1c8f2727e9f5 157 p_CB = p_task->p_rlnk;
y7jin 0:1c8f2727e9f5 158 while (p_CB->cb_type == TCB) {
y7jin 0:1c8f2727e9f5 159 /* Find a header of this task chain list. */
y7jin 0:1c8f2727e9f5 160 p_CB = p_CB->p_rlnk;
y7jin 0:1c8f2727e9f5 161 }
y7jin 0:1c8f2727e9f5 162 res:rt_rmv_list (p_task);
y7jin 0:1c8f2727e9f5 163 rt_put_prio ((P_XCB)p_CB, p_task);
y7jin 0:1c8f2727e9f5 164 }
y7jin 0:1c8f2727e9f5 165 }
y7jin 0:1c8f2727e9f5 166
y7jin 0:1c8f2727e9f5 167
y7jin 0:1c8f2727e9f5 168 /*--------------------------- rt_put_dly ------------------------------------*/
y7jin 0:1c8f2727e9f5 169
y7jin 0:1c8f2727e9f5 170 void rt_put_dly (P_TCB p_task, U16 delay) {
y7jin 0:1c8f2727e9f5 171 /* Put a task identified with "p_task" into chained delay wait list using */
y7jin 0:1c8f2727e9f5 172 /* a delay value of "delay". */
y7jin 0:1c8f2727e9f5 173 P_TCB p;
y7jin 0:1c8f2727e9f5 174 U32 delta,idelay = delay;
y7jin 0:1c8f2727e9f5 175
y7jin 0:1c8f2727e9f5 176 p = (P_TCB)&os_dly;
y7jin 0:1c8f2727e9f5 177 if (p->p_dlnk == NULL) {
y7jin 0:1c8f2727e9f5 178 /* Delay list empty */
y7jin 0:1c8f2727e9f5 179 delta = 0;
y7jin 0:1c8f2727e9f5 180 goto last;
y7jin 0:1c8f2727e9f5 181 }
y7jin 0:1c8f2727e9f5 182 delta = os_dly.delta_time;
y7jin 0:1c8f2727e9f5 183 while (delta < idelay) {
y7jin 0:1c8f2727e9f5 184 if (p->p_dlnk == NULL) {
y7jin 0:1c8f2727e9f5 185 /* End of list found */
y7jin 0:1c8f2727e9f5 186 last: p_task->p_dlnk = NULL;
y7jin 0:1c8f2727e9f5 187 p->p_dlnk = p_task;
y7jin 0:1c8f2727e9f5 188 p_task->p_blnk = p;
y7jin 0:1c8f2727e9f5 189 p->delta_time = (U16)(idelay - delta);
y7jin 0:1c8f2727e9f5 190 p_task->delta_time = 0;
y7jin 0:1c8f2727e9f5 191 return;
y7jin 0:1c8f2727e9f5 192 }
y7jin 0:1c8f2727e9f5 193 p = p->p_dlnk;
y7jin 0:1c8f2727e9f5 194 delta += p->delta_time;
y7jin 0:1c8f2727e9f5 195 }
y7jin 0:1c8f2727e9f5 196 /* Right place found */
y7jin 0:1c8f2727e9f5 197 p_task->p_dlnk = p->p_dlnk;
y7jin 0:1c8f2727e9f5 198 p->p_dlnk = p_task;
y7jin 0:1c8f2727e9f5 199 p_task->p_blnk = p;
y7jin 0:1c8f2727e9f5 200 if (p_task->p_dlnk != NULL) {
y7jin 0:1c8f2727e9f5 201 p_task->p_dlnk->p_blnk = p_task;
y7jin 0:1c8f2727e9f5 202 }
y7jin 0:1c8f2727e9f5 203 p_task->delta_time = (U16)(delta - idelay);
y7jin 0:1c8f2727e9f5 204 p->delta_time -= p_task->delta_time;
y7jin 0:1c8f2727e9f5 205 }
y7jin 0:1c8f2727e9f5 206
y7jin 0:1c8f2727e9f5 207
y7jin 0:1c8f2727e9f5 208 /*--------------------------- rt_dec_dly ------------------------------------*/
y7jin 0:1c8f2727e9f5 209
y7jin 0:1c8f2727e9f5 210 void rt_dec_dly (void) {
y7jin 0:1c8f2727e9f5 211 /* Decrement delta time of list head: remove tasks having a value of zero.*/
y7jin 0:1c8f2727e9f5 212 P_TCB p_rdy;
y7jin 0:1c8f2727e9f5 213
y7jin 0:1c8f2727e9f5 214 if (os_dly.p_dlnk == NULL) {
y7jin 0:1c8f2727e9f5 215 return;
y7jin 0:1c8f2727e9f5 216 }
y7jin 0:1c8f2727e9f5 217 os_dly.delta_time--;
y7jin 0:1c8f2727e9f5 218 while ((os_dly.delta_time == 0) && (os_dly.p_dlnk != NULL)) {
y7jin 0:1c8f2727e9f5 219 p_rdy = os_dly.p_dlnk;
y7jin 0:1c8f2727e9f5 220 if (p_rdy->p_rlnk != NULL) {
y7jin 0:1c8f2727e9f5 221 /* Task is really enqueued, remove task from semaphore/mailbox */
y7jin 0:1c8f2727e9f5 222 /* timeout waiting list. */
y7jin 0:1c8f2727e9f5 223 p_rdy->p_rlnk->p_lnk = p_rdy->p_lnk;
y7jin 0:1c8f2727e9f5 224 if (p_rdy->p_lnk != NULL) {
y7jin 0:1c8f2727e9f5 225 p_rdy->p_lnk->p_rlnk = p_rdy->p_rlnk;
y7jin 0:1c8f2727e9f5 226 p_rdy->p_lnk = NULL;
y7jin 0:1c8f2727e9f5 227 }
y7jin 0:1c8f2727e9f5 228 p_rdy->p_rlnk = NULL;
y7jin 0:1c8f2727e9f5 229 }
y7jin 0:1c8f2727e9f5 230 rt_put_prio (&os_rdy, p_rdy);
y7jin 0:1c8f2727e9f5 231 os_dly.delta_time = p_rdy->delta_time;
y7jin 0:1c8f2727e9f5 232 if (p_rdy->state == WAIT_ITV) {
y7jin 0:1c8f2727e9f5 233 /* Calculate the next time for interval wait. */
y7jin 0:1c8f2727e9f5 234 p_rdy->delta_time = p_rdy->interval_time + (U16)os_time;
y7jin 0:1c8f2727e9f5 235 }
y7jin 0:1c8f2727e9f5 236 p_rdy->state = READY;
y7jin 0:1c8f2727e9f5 237 os_dly.p_dlnk = p_rdy->p_dlnk;
y7jin 0:1c8f2727e9f5 238 if (p_rdy->p_dlnk != NULL) {
y7jin 0:1c8f2727e9f5 239 p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly;
y7jin 0:1c8f2727e9f5 240 p_rdy->p_dlnk = NULL;
y7jin 0:1c8f2727e9f5 241 }
y7jin 0:1c8f2727e9f5 242 p_rdy->p_blnk = NULL;
y7jin 0:1c8f2727e9f5 243 }
y7jin 0:1c8f2727e9f5 244 }
y7jin 0:1c8f2727e9f5 245
y7jin 0:1c8f2727e9f5 246
y7jin 0:1c8f2727e9f5 247 /*--------------------------- rt_rmv_list -----------------------------------*/
y7jin 0:1c8f2727e9f5 248
y7jin 0:1c8f2727e9f5 249 void rt_rmv_list (P_TCB p_task) {
y7jin 0:1c8f2727e9f5 250 /* Remove task identified with "p_task" from ready, semaphore or mailbox */
y7jin 0:1c8f2727e9f5 251 /* waiting list if enqueued. */
y7jin 0:1c8f2727e9f5 252 P_TCB p_b;
y7jin 0:1c8f2727e9f5 253
y7jin 0:1c8f2727e9f5 254 if (p_task->p_rlnk != NULL) {
y7jin 0:1c8f2727e9f5 255 /* A task is enqueued in semaphore / mailbox waiting list. */
y7jin 0:1c8f2727e9f5 256 p_task->p_rlnk->p_lnk = p_task->p_lnk;
y7jin 0:1c8f2727e9f5 257 if (p_task->p_lnk != NULL) {
y7jin 0:1c8f2727e9f5 258 p_task->p_lnk->p_rlnk = p_task->p_rlnk;
y7jin 0:1c8f2727e9f5 259 }
y7jin 0:1c8f2727e9f5 260 return;
y7jin 0:1c8f2727e9f5 261 }
y7jin 0:1c8f2727e9f5 262
y7jin 0:1c8f2727e9f5 263 p_b = (P_TCB)&os_rdy;
y7jin 0:1c8f2727e9f5 264 while (p_b != NULL) {
y7jin 0:1c8f2727e9f5 265 /* Search the ready list for task "p_task" */
y7jin 0:1c8f2727e9f5 266 if (p_b->p_lnk == p_task) {
y7jin 0:1c8f2727e9f5 267 p_b->p_lnk = p_task->p_lnk;
y7jin 0:1c8f2727e9f5 268 return;
y7jin 0:1c8f2727e9f5 269 }
y7jin 0:1c8f2727e9f5 270 p_b = p_b->p_lnk;
y7jin 0:1c8f2727e9f5 271 }
y7jin 0:1c8f2727e9f5 272 }
y7jin 0:1c8f2727e9f5 273
y7jin 0:1c8f2727e9f5 274
y7jin 0:1c8f2727e9f5 275 /*--------------------------- rt_rmv_dly ------------------------------------*/
y7jin 0:1c8f2727e9f5 276
y7jin 0:1c8f2727e9f5 277 void rt_rmv_dly (P_TCB p_task) {
y7jin 0:1c8f2727e9f5 278 /* Remove task identified with "p_task" from delay list if enqueued. */
y7jin 0:1c8f2727e9f5 279 P_TCB p_b;
y7jin 0:1c8f2727e9f5 280
y7jin 0:1c8f2727e9f5 281 p_b = p_task->p_blnk;
y7jin 0:1c8f2727e9f5 282 if (p_b != NULL) {
y7jin 0:1c8f2727e9f5 283 /* Task is really enqueued */
y7jin 0:1c8f2727e9f5 284 p_b->p_dlnk = p_task->p_dlnk;
y7jin 0:1c8f2727e9f5 285 if (p_task->p_dlnk != NULL) {
y7jin 0:1c8f2727e9f5 286 /* 'p_task' is in the middle of list */
y7jin 0:1c8f2727e9f5 287 p_b->delta_time += p_task->delta_time;
y7jin 0:1c8f2727e9f5 288 p_task->p_dlnk->p_blnk = p_b;
y7jin 0:1c8f2727e9f5 289 p_task->p_dlnk = NULL;
y7jin 0:1c8f2727e9f5 290 }
y7jin 0:1c8f2727e9f5 291 else {
y7jin 0:1c8f2727e9f5 292 /* 'p_task' is at the end of list */
y7jin 0:1c8f2727e9f5 293 p_b->delta_time = 0;
y7jin 0:1c8f2727e9f5 294 }
y7jin 0:1c8f2727e9f5 295 p_task->p_blnk = NULL;
y7jin 0:1c8f2727e9f5 296 }
y7jin 0:1c8f2727e9f5 297 }
y7jin 0:1c8f2727e9f5 298
y7jin 0:1c8f2727e9f5 299
y7jin 0:1c8f2727e9f5 300 /*--------------------------- rt_psq_enq ------------------------------------*/
y7jin 0:1c8f2727e9f5 301
y7jin 0:1c8f2727e9f5 302 void rt_psq_enq (OS_ID entry, U32 arg) {
y7jin 0:1c8f2727e9f5 303 /* Insert post service request "entry" into ps-queue. */
y7jin 0:1c8f2727e9f5 304 U32 idx;
y7jin 0:1c8f2727e9f5 305
y7jin 0:1c8f2727e9f5 306 idx = rt_inc_qi (os_psq->size, &os_psq->count, &os_psq->first);
y7jin 0:1c8f2727e9f5 307 if (idx < os_psq->size) {
y7jin 0:1c8f2727e9f5 308 os_psq->q[idx].id = entry;
y7jin 0:1c8f2727e9f5 309 os_psq->q[idx].arg = arg;
y7jin 0:1c8f2727e9f5 310 }
y7jin 0:1c8f2727e9f5 311 else {
y7jin 0:1c8f2727e9f5 312 os_error (OS_ERR_FIFO_OVF);
y7jin 0:1c8f2727e9f5 313 }
y7jin 0:1c8f2727e9f5 314 }
y7jin 0:1c8f2727e9f5 315
y7jin 0:1c8f2727e9f5 316
y7jin 0:1c8f2727e9f5 317 /*----------------------------------------------------------------------------
y7jin 0:1c8f2727e9f5 318 * end of file
y7jin 0:1c8f2727e9f5 319 *---------------------------------------------------------------------------*/
y7jin 0:1c8f2727e9f5 320