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