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