Counter

Dependencies:   EthernetInterface NTPClient SDFileSystem TextLCD WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip FATFileSystem

Committer:
Tuxitheone
Date:
Mon Feb 29 18:59:15 2016 +0000
Revision:
0:ecaf3e593122
TankCounter

Who changed what in which revision?

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