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