训练营PLSR题目
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

603 rindas
26 KiB

  1. /*
  2. ***********************************************************************************************************************
  3. * uC/OS-III
  4. * The Real-Time Kernel
  5. *
  6. * (c) Copyright 2009-2014; Micrium, Inc.; Weston, FL
  7. * All rights reserved. Protected by international copyright laws.
  8. *
  9. * TICK MANAGEMENT
  10. *
  11. * File : OS_TICK.C
  12. * By : JJL
  13. * Version : V3.04.04
  14. *
  15. * LICENSING TERMS:
  16. * ---------------
  17. * uC/OS-III is provided in source form for FREE short-term evaluation, for educational use or
  18. * for peaceful research. If you plan or intend to use uC/OS-III in a commercial application/
  19. * product then, you need to contact Micrium to properly license uC/OS-III for its use in your
  20. * application/product. We provide ALL the source code for your convenience and to help you
  21. * experience uC/OS-III. The fact that the source is provided does NOT mean that you can use
  22. * it commercially without paying a licensing fee.
  23. *
  24. * Knowledge of the source code may NOT be used to develop a similar product.
  25. *
  26. * Please help us continue to provide the embedded community with the finest software available.
  27. * Your honesty is greatly appreciated.
  28. *
  29. * You can find our product's user manual, API reference, release notes and
  30. * more information at https://doc.micrium.com.
  31. * You can contact us at www.micrium.com.
  32. ************************************************************************************************************************
  33. */
  34. #define MICRIUM_SOURCE
  35. #include "os.h"
  36. #ifdef VSC_INCLUDE_SOURCE_FILE_NAMES
  37. const CPU_CHAR *os_tick__c = "$Id: $";
  38. #endif
  39. /*
  40. ************************************************************************************************************************
  41. * FUNCTION PROTOTYPES
  42. ************************************************************************************************************************
  43. */
  44. static CPU_TS OS_TickListUpdateDly (void);
  45. static CPU_TS OS_TickListUpdateTimeout (void);
  46. /*
  47. ************************************************************************************************************************
  48. * TICK TASK
  49. *
  50. * Description: This task is internal to uC/OS-III and is triggered by the tick interrupt.
  51. *
  52. * Arguments : p_arg is an argument passed to the task when the task is created (unused).
  53. *
  54. * Returns : none
  55. *
  56. * Note(s) : This function is INTERNAL to uC/OS-III and your application should not call it.
  57. ************************************************************************************************************************
  58. */
  59. void OS_TickTask (void *p_arg)
  60. {
  61. OS_ERR err;
  62. CPU_TS ts_delta;
  63. CPU_TS ts_delta_dly;
  64. CPU_TS ts_delta_timeout;
  65. CPU_SR_ALLOC();
  66. (void)&p_arg; /* Prevent compiler warning */
  67. while (DEF_ON) {
  68. (void)OSTaskSemPend((OS_TICK )0,
  69. (OS_OPT )OS_OPT_PEND_BLOCKING,
  70. (CPU_TS *)0,
  71. (OS_ERR *)&err); /* Wait for signal from tick interrupt */
  72. if (err == OS_ERR_NONE) {
  73. OS_CRITICAL_ENTER();
  74. OSTickCtr++; /* Keep track of the number of ticks */
  75. #if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN > 0u))
  76. TRACE_OS_TICK_INCREMENT(OSTickCtr); /* Record the event. */
  77. #endif
  78. OS_CRITICAL_EXIT();
  79. ts_delta_dly = OS_TickListUpdateDly();
  80. ts_delta_timeout = OS_TickListUpdateTimeout();
  81. ts_delta = ts_delta_dly + ts_delta_timeout; /* Compute total execution time of list updates */
  82. if (OSTickTaskTimeMax < ts_delta) {
  83. OSTickTaskTimeMax = ts_delta;
  84. }
  85. }
  86. }
  87. }
  88. /*
  89. ************************************************************************************************************************
  90. * INITIALIZE TICK TASK
  91. *
  92. * Description: This function is called by OSInit() to create the tick task.
  93. *
  94. * Arguments : p_err is a pointer to a variable that will hold the value of an error code:
  95. *
  96. * OS_ERR_TICK_STK_INVALID if the pointer to the tick task stack is a NULL pointer
  97. * OS_ERR_TICK_STK_SIZE indicates that the specified stack size
  98. * OS_ERR_PRIO_INVALID if the priority you specified in the configuration is invalid
  99. * (There could be only one task at the Idle Task priority)
  100. * (Maybe the priority you specified is higher than OS_CFG_PRIO_MAX-1
  101. * OS_ERR_?? other error code returned by OSTaskCreate()
  102. *
  103. * Returns : none
  104. *
  105. * Note(s) : This function is INTERNAL to uC/OS-III and your application should not call it.
  106. ************************************************************************************************************************
  107. */
  108. void OS_TickTaskInit (OS_ERR *p_err)
  109. {
  110. #ifdef OS_SAFETY_CRITICAL
  111. if (p_err == (OS_ERR *)0) {
  112. OS_SAFETY_CRITICAL_EXCEPTION();
  113. return;
  114. }
  115. #endif
  116. OSTickCtr = (OS_TICK)0u; /* Clear the tick counter */
  117. OSTickListDly.TCB_Ptr = (OS_TCB *)0;
  118. OSTickListTimeout.TCB_Ptr = (OS_TCB *)0;
  119. #if OS_CFG_DBG_EN > 0u
  120. OSTickListDly.NbrEntries = (OS_OBJ_QTY)0;
  121. OSTickListDly.NbrUpdated = (OS_OBJ_QTY)0;
  122. OSTickListTimeout.NbrEntries = (OS_OBJ_QTY)0;
  123. OSTickListTimeout.NbrUpdated = (OS_OBJ_QTY)0;
  124. #endif
  125. /* ---------------- CREATE THE TICK TASK ----------- */
  126. if (OSCfg_TickTaskStkBasePtr == (CPU_STK *)0) {
  127. *p_err = OS_ERR_TICK_STK_INVALID;
  128. return;
  129. }
  130. if (OSCfg_TickTaskStkSize < OSCfg_StkSizeMin) {
  131. *p_err = OS_ERR_TICK_STK_SIZE_INVALID;
  132. return;
  133. }
  134. if (OSCfg_TickTaskPrio >= (OS_CFG_PRIO_MAX - 1u)) { /* Only one task at the 'Idle Task' priority */
  135. *p_err = OS_ERR_TICK_PRIO_INVALID;
  136. return;
  137. }
  138. OSTaskCreate((OS_TCB *)&OSTickTaskTCB,
  139. (CPU_CHAR *)((void *)"uC/OS-III Tick Task"),
  140. (OS_TASK_PTR )OS_TickTask,
  141. (void *)0,
  142. (OS_PRIO )OSCfg_TickTaskPrio,
  143. (CPU_STK *)OSCfg_TickTaskStkBasePtr,
  144. (CPU_STK_SIZE)OSCfg_TickTaskStkLimit,
  145. (CPU_STK_SIZE)OSCfg_TickTaskStkSize,
  146. (OS_MSG_QTY )0u,
  147. (OS_TICK )0u,
  148. (void *)0,
  149. (OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR | OS_OPT_TASK_NO_TLS),
  150. (OS_ERR *)p_err);
  151. }
  152. /*
  153. ************************************************************************************************************************
  154. * INSERT
  155. *
  156. * Description: This task is internal to uC/OS-III and allows the insertion of a task in a tick list.
  157. *
  158. * Arguments : p_list is a pointer to the desired list
  159. *
  160. * p_tcb is a pointer to the TCB to insert in the list
  161. *
  162. * time is the amount of time remaining (in ticks) for the task to become ready
  163. *
  164. * Returns : none
  165. *
  166. * Note(s) : This function is INTERNAL to uC/OS-III and your application should not call it.
  167. ************************************************************************************************************************
  168. */
  169. void OS_TickListInsert (OS_TICK_LIST *p_list,
  170. OS_TCB *p_tcb,
  171. OS_TICK time)
  172. {
  173. OS_TCB *p_tcb1;
  174. OS_TCB *p_tcb2;
  175. OS_TICK remain;
  176. if (p_list->TCB_Ptr == (OS_TCB *)0) { /* Is the list empty? */
  177. p_tcb->TickRemain = time; /* Yes, Store time in TCB */
  178. p_tcb->TickNextPtr = (OS_TCB *)0;
  179. p_tcb->TickPrevPtr = (OS_TCB *)0;
  180. p_tcb->TickListPtr = (OS_TICK_LIST *)p_list; /* Link to this list */
  181. p_list->TCB_Ptr = p_tcb; /* Point to TCB of task to place in the list */
  182. #if OS_CFG_DBG_EN > 0u
  183. p_list->NbrEntries = 1u; /* List contains 1 entry */
  184. #endif
  185. } else {
  186. p_tcb1 = p_list->TCB_Ptr;
  187. p_tcb2 = p_list->TCB_Ptr; /* No, Insert somewhere in the list in delta order */
  188. remain = time;
  189. while (p_tcb2 != (OS_TCB *)0) {
  190. if (remain <= p_tcb2->TickRemain) {
  191. if (p_tcb2->TickPrevPtr == (OS_TCB *)0) { /* Insert before the first entry in the list? */
  192. p_tcb->TickRemain = remain; /* Yes, Store remaining time */
  193. p_tcb->TickPrevPtr = (OS_TCB *)0;
  194. p_tcb->TickNextPtr = p_tcb2;
  195. p_tcb->TickListPtr = (OS_TICK_LIST *)p_list; /* Link TCB to this list */
  196. p_tcb2->TickRemain -= remain; /* Reduce time of next entry in the list */
  197. p_tcb2->TickPrevPtr = p_tcb;
  198. p_list->TCB_Ptr = p_tcb; /* Add TCB to the list */
  199. #if OS_CFG_DBG_EN > 0u
  200. p_list->NbrEntries++; /* List contains an extra entry */
  201. #endif
  202. } else { /* No, Insert somewhere further in the list */
  203. p_tcb1 = p_tcb2->TickPrevPtr;
  204. p_tcb->TickRemain = remain; /* Store remaining time */
  205. p_tcb->TickPrevPtr = p_tcb1;
  206. p_tcb->TickNextPtr = p_tcb2;
  207. p_tcb->TickListPtr = (OS_TICK_LIST *)p_list; /* TCB points to this list */
  208. p_tcb2->TickRemain -= remain; /* Reduce time of next entry in the list */
  209. p_tcb2->TickPrevPtr = p_tcb;
  210. p_tcb1->TickNextPtr = p_tcb;
  211. #if OS_CFG_DBG_EN > 0u
  212. p_list->NbrEntries++; /* List contains an extra entry */
  213. #endif
  214. }
  215. return;
  216. } else {
  217. remain -= p_tcb2->TickRemain; /* Point to the next TCB in the list */
  218. p_tcb1 = p_tcb2;
  219. p_tcb2 = p_tcb2->TickNextPtr;
  220. }
  221. }
  222. p_tcb->TickRemain = remain;
  223. p_tcb->TickPrevPtr = p_tcb1;
  224. p_tcb->TickNextPtr = (OS_TCB *)0;
  225. p_tcb->TickListPtr = (OS_TICK_LIST *)p_list; /* Link the list to the TCB */
  226. p_tcb1->TickNextPtr = p_tcb;
  227. #if OS_CFG_DBG_EN > 0u
  228. p_list->NbrEntries++; /* List contains an extra entry */
  229. #endif
  230. }
  231. }
  232. /*
  233. ************************************************************************************************************************
  234. * ADD TASK TO DELAYED TICK LIST
  235. *
  236. * Description: This function is called to place a task in a list of task waiting for either time to expire
  237. *
  238. * Arguments : p_tcb is a pointer to the OS_TCB of the task to add to the tick list
  239. * -----
  240. *
  241. * time represents either the 'match' value of OSTickCtr or a relative time from the current
  242. * value of OSTickCtr as specified by the 'opt' argument..
  243. *
  244. * relative when 'opt' is set to OS_OPT_TIME_DLY
  245. * relative when 'opt' is set to OS_OPT_TIME_TIMEOUT
  246. * match when 'opt' is set to OS_OPT_TIME_MATCH
  247. * periodic when 'opt' is set to OS_OPT_TIME_PERIODIC
  248. *
  249. * opt is an option specifying how to calculate time. The valid values are:
  250. * ---
  251. * OS_OPT_TIME_DLY
  252. * OS_OPT_TIME_TIMEOUT
  253. * OS_OPT_TIME_PERIODIC
  254. * OS_OPT_TIME_MATCH
  255. *
  256. * p_err is a pointer to a variable that will contain an error code returned by this function.
  257. * -----
  258. * OS_ERR_NONE the call was successful and the time delay was scheduled.
  259. * OS_ERR_TIME_ZERO_DLY if delay is zero or already occurred.
  260. *
  261. * Returns : None
  262. *
  263. * Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
  264. *
  265. * 2) This function is assumed to be called with interrupts disabled.
  266. ************************************************************************************************************************
  267. */
  268. void OS_TickListInsertDly (OS_TCB *p_tcb,
  269. OS_TICK time,
  270. OS_OPT opt,
  271. OS_ERR *p_err)
  272. {
  273. OS_TICK remain;
  274. if (opt == OS_OPT_TIME_MATCH) { /* MATCH to absolute OSTickCtr value mode */
  275. remain = time - OSTickCtr;
  276. if ((remain > OS_TICK_TH_RDY) || /* If delay already occurred, ... */
  277. (remain == (OS_TICK)0u)) {
  278. p_tcb->TickRemain = (OS_TICK)0u;
  279. *p_err = OS_ERR_TIME_ZERO_DLY; /* ... do NOT delay. */
  280. return;
  281. }
  282. } else if (opt == OS_OPT_TIME_PERIODIC) { /* PERIODIC mode. */
  283. if ((OSTickCtr - p_tcb->TickCtrPrev) > time) {
  284. remain = time; /* ... first time we load .TickCtrPrev */
  285. p_tcb->TickCtrPrev = OSTickCtr + time;
  286. } else {
  287. remain = time - (OSTickCtr - p_tcb->TickCtrPrev);
  288. if ((remain > OS_TICK_TH_RDY) || /* If delay time has already passed, ... */
  289. (remain == (OS_TICK)0u)) {
  290. p_tcb->TickCtrPrev += time + time * ((OSTickCtr - p_tcb->TickCtrPrev) / time); /* Try to recover the period */
  291. p_tcb->TickRemain = (OS_TICK)0u;
  292. *p_err = OS_ERR_TIME_ZERO_DLY; /* ... do NOT delay. */
  293. return;
  294. }
  295. p_tcb->TickCtrPrev += time;
  296. }
  297. } else if (time > (OS_TICK)0u) { /* RELATIVE time delay mode */
  298. remain = time;
  299. } else { /* Zero time delay; ... */
  300. p_tcb->TickRemain = (OS_TICK)0u;
  301. *p_err = OS_ERR_TIME_ZERO_DLY; /* ... do NOT delay. */
  302. return;
  303. }
  304. p_tcb->TaskState = OS_TASK_STATE_DLY;
  305. OS_TickListInsert(&OSTickListDly, p_tcb, remain);
  306. *p_err = OS_ERR_NONE;
  307. }
  308. /*
  309. ************************************************************************************************************************
  310. * REMOVE A TASK FROM THE TICK LIST
  311. *
  312. * Description: This function is called to remove a task from the tick list
  313. *
  314. * Arguments : p_tcb Is a pointer to the OS_TCB to remove.
  315. * -----
  316. *
  317. * Returns : none
  318. *
  319. * Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
  320. *
  321. * 2) This function is assumed to be called with interrupts disabled.
  322. ************************************************************************************************************************
  323. */
  324. void OS_TickListRemove (OS_TCB *p_tcb)
  325. {
  326. OS_TICK_LIST *p_list;
  327. OS_TCB *p_tcb1;
  328. OS_TCB *p_tcb2;
  329. p_list = (OS_TICK_LIST *)p_tcb->TickListPtr;
  330. p_tcb1 = p_tcb->TickPrevPtr;
  331. p_tcb2 = p_tcb->TickNextPtr;
  332. if (p_tcb1 == (OS_TCB *)0) {
  333. if (p_tcb2 == (OS_TCB *)0) { /* Remove ONLY entry in the list? */
  334. p_list->TCB_Ptr = (OS_TCB *)0;
  335. #if OS_CFG_DBG_EN > 0u
  336. p_list->NbrEntries = (OS_OBJ_QTY )0u;
  337. #endif
  338. p_tcb->TickRemain = (OS_TICK )0u;
  339. p_tcb->TickListPtr = (OS_TICK_LIST *)0;
  340. } else {
  341. p_tcb2->TickPrevPtr = (OS_TCB *)0;
  342. p_tcb2->TickRemain += p_tcb->TickRemain; /* Add back the ticks to the delta */
  343. p_list->TCB_Ptr = p_tcb2;
  344. #if OS_CFG_DBG_EN > 0u
  345. p_list->NbrEntries--;
  346. #endif
  347. p_tcb->TickNextPtr = (OS_TCB *)0;
  348. p_tcb->TickRemain = (OS_TICK )0u;
  349. p_tcb->TickListPtr = (OS_TICK_LIST *)0;
  350. }
  351. } else {
  352. p_tcb1->TickNextPtr = p_tcb2;
  353. if (p_tcb2 != (OS_TCB *)0) {
  354. p_tcb2->TickPrevPtr = p_tcb1;
  355. p_tcb2->TickRemain += p_tcb->TickRemain; /* Add back the ticks to the delta list */
  356. }
  357. p_tcb->TickPrevPtr = (OS_TCB *)0;
  358. #if OS_CFG_DBG_EN > 0u
  359. p_list->NbrEntries--;
  360. #endif
  361. p_tcb->TickNextPtr = (OS_TCB *)0;
  362. p_tcb->TickRemain = (OS_TICK )0u;
  363. p_tcb->TickListPtr = (OS_TICK_LIST *)0;
  364. }
  365. }
  366. /*
  367. ************************************************************************************************************************
  368. * RESET TICK LIST PEAK DETECTOR
  369. *
  370. * Description: This function is used to reset the peak detector for the number of entries in each spoke.
  371. *
  372. * Arguments : void
  373. *
  374. * Returns : none
  375. *
  376. * Note(s) : This function is INTERNAL to uC/OS-III and your application should not call it.
  377. ************************************************************************************************************************
  378. */
  379. void OS_TickListResetPeak (void)
  380. {
  381. #if OS_CFG_DBG_EN > 0u
  382. #endif
  383. }
  384. /*
  385. ************************************************************************************************************************
  386. * UPDATE THE LIST OF TASKS DELAYED
  387. *
  388. * Description: This function updates the delta list which contains tasks that have been delayed.
  389. *
  390. * Arguments : non
  391. *
  392. * Returns : none
  393. *
  394. * Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
  395. ************************************************************************************************************************
  396. */
  397. static CPU_TS OS_TickListUpdateDly (void)
  398. {
  399. OS_TCB *p_tcb;
  400. OS_TICK_LIST *p_list;
  401. CPU_TS ts_start;
  402. CPU_TS ts_delta_dly;
  403. #if OS_CFG_DBG_EN > 0u
  404. OS_OBJ_QTY nbr_updated;
  405. #endif
  406. CPU_SR_ALLOC();
  407. OS_CRITICAL_ENTER();
  408. ts_start = OS_TS_GET();
  409. #if OS_CFG_DBG_EN > 0u
  410. nbr_updated = (OS_OBJ_QTY)0u;
  411. #endif
  412. p_list = &OSTickListDly;
  413. p_tcb = p_list->TCB_Ptr;
  414. if (p_tcb != (OS_TCB *)0) {
  415. p_tcb->TickRemain--;
  416. while (p_tcb->TickRemain == 0u) {
  417. #if OS_CFG_DBG_EN > 0u
  418. nbr_updated++; /* Keep track of the number of TCBs updated */
  419. #endif
  420. if (p_tcb->TaskState == OS_TASK_STATE_DLY) {
  421. p_tcb->TaskState = OS_TASK_STATE_RDY;
  422. OS_RdyListInsert(p_tcb); /* Insert the task in the ready list */
  423. } else if (p_tcb->TaskState == OS_TASK_STATE_DLY_SUSPENDED) {
  424. p_tcb->TaskState = OS_TASK_STATE_SUSPENDED;
  425. }
  426. p_list->TCB_Ptr = p_tcb->TickNextPtr;
  427. p_tcb = p_list->TCB_Ptr; /* Get 'p_tcb' again for loop */
  428. if (p_tcb == (OS_TCB *)0) {
  429. #if OS_CFG_DBG_EN > 0u
  430. p_list->NbrEntries = (OS_OBJ_QTY)0u;
  431. #endif
  432. break;
  433. } else {
  434. #if OS_CFG_DBG_EN > 0u
  435. p_list->NbrEntries--;
  436. #endif
  437. p_tcb->TickPrevPtr = (OS_TCB *)0;
  438. }
  439. }
  440. }
  441. #if OS_CFG_DBG_EN > 0u
  442. p_list->NbrUpdated = nbr_updated;
  443. #endif
  444. ts_delta_dly = OS_TS_GET() - ts_start; /* Measure execution time of the update */
  445. OS_CRITICAL_EXIT();
  446. return (ts_delta_dly);
  447. }
  448. /*
  449. ************************************************************************************************************************
  450. * UPDATE THE LIST OF TASKS PENDING WITH TIMEOUT
  451. *
  452. * Description: This function updales the delta list which contains tasks that are pending with a timeout.
  453. *
  454. * Arguments : non
  455. *
  456. * Returns : none
  457. *
  458. * Note(s) : 1) This function is INTERNAL to uC/OS-III and your application MUST NOT call it.
  459. ************************************************************************************************************************
  460. */
  461. static CPU_TS OS_TickListUpdateTimeout (void)
  462. {
  463. OS_TCB *p_tcb;
  464. OS_TICK_LIST *p_list;
  465. CPU_TS ts_start;
  466. CPU_TS ts_delta_timeout;
  467. #if OS_CFG_DBG_EN > 0u
  468. OS_OBJ_QTY nbr_updated;
  469. #endif
  470. #if OS_CFG_MUTEX_EN > 0u
  471. OS_TCB *p_tcb_owner;
  472. OS_PRIO prio_new;
  473. #endif
  474. CPU_SR_ALLOC();
  475. OS_CRITICAL_ENTER(); /* ======= UPDATE TASKS WAITING WITH TIMEOUT ======= */
  476. ts_start = OS_TS_GET();
  477. #if OS_CFG_DBG_EN > 0u
  478. nbr_updated = (OS_OBJ_QTY)0u;
  479. #endif
  480. p_list = &OSTickListTimeout;
  481. p_tcb = p_list->TCB_Ptr;
  482. if (p_tcb != (OS_TCB *)0) {
  483. p_tcb->TickRemain--;
  484. while (p_tcb->TickRemain == 0u) {
  485. #if OS_CFG_DBG_EN > 0u
  486. nbr_updated++;
  487. #endif
  488. #if OS_CFG_MUTEX_EN > 0u
  489. p_tcb_owner = (OS_TCB *)0;
  490. if (p_tcb->PendOn == OS_TASK_PEND_ON_MUTEX) {
  491. p_tcb_owner = ((OS_MUTEX *)p_tcb->PendDataTblPtr->PendObjPtr)->OwnerTCBPtr;
  492. }
  493. #endif
  494. #if (OS_MSG_EN > 0u)
  495. p_tcb->MsgPtr = (void *)0;
  496. p_tcb->MsgSize = (OS_MSG_SIZE)0u;
  497. #endif
  498. p_tcb->TS = OS_TS_GET();
  499. OS_PendListRemove(p_tcb); /* Remove from wait list */
  500. if (p_tcb->TaskState == OS_TASK_STATE_PEND_TIMEOUT) {
  501. OS_RdyListInsert(p_tcb); /* Insert the task in the ready list */
  502. p_tcb->TaskState = OS_TASK_STATE_RDY;
  503. } else if (p_tcb->TaskState == OS_TASK_STATE_PEND_TIMEOUT_SUSPENDED) {
  504. p_tcb->TaskState = OS_TASK_STATE_SUSPENDED;
  505. }
  506. p_tcb->PendStatus = OS_STATUS_PEND_TIMEOUT; /* Indicate pend timed out */
  507. p_tcb->PendOn = OS_TASK_PEND_ON_NOTHING; /* Indicate no longer pending */
  508. #if OS_CFG_MUTEX_EN > 0u
  509. if(p_tcb_owner != (OS_TCB *)0) {
  510. if ((p_tcb_owner->Prio != p_tcb_owner->BasePrio) &&
  511. (p_tcb_owner->Prio == p_tcb->Prio)) { /* Has the owner inherited a priority? */
  512. prio_new = OS_MutexGrpPrioFindHighest(p_tcb_owner);
  513. prio_new = prio_new > p_tcb_owner->BasePrio ? p_tcb_owner->BasePrio : prio_new;
  514. if(prio_new != p_tcb_owner->Prio) {
  515. OS_TaskChangePrio(p_tcb_owner, prio_new);
  516. #if (defined(TRACE_CFG_EN) && (TRACE_CFG_EN > 0u))
  517. TRACE_OS_MUTEX_TASK_PRIO_DISINHERIT(p_tcb_owner, p_tcb_owner->Prio)
  518. #endif
  519. }
  520. }
  521. }
  522. #endif
  523. p_list->TCB_Ptr = p_tcb->TickNextPtr;
  524. p_tcb = p_list->TCB_Ptr; /* Get 'p_tcb' again for loop */
  525. if (p_tcb == (OS_TCB *)0) {
  526. #if OS_CFG_DBG_EN > 0u
  527. p_list->NbrEntries = (OS_OBJ_QTY)0u;
  528. #endif
  529. break;
  530. } else {
  531. #if OS_CFG_DBG_EN > 0u
  532. p_list->NbrEntries--;
  533. #endif
  534. p_tcb->TickPrevPtr = (OS_TCB *)0;
  535. }
  536. }
  537. }
  538. #if OS_CFG_DBG_EN > 0u
  539. p_list->NbrUpdated = nbr_updated;
  540. #endif
  541. ts_delta_timeout = OS_TS_GET() - ts_start; /* Measure execution time of the update */
  542. OS_CRITICAL_EXIT(); /* ------------------------------------------------- */
  543. return (ts_delta_timeout);
  544. }