1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** ThreadX Component */ 17 /** */ 18 /** Timer */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define TX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "tx_api.h" 29 #include "tx_timer.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _tx_timer_system_deactivate PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* William E. Lamie, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function deactivates, or removes the timer from the active */ 45 /* timer expiration list. If the timer is already deactivated, this */ 46 /* function just returns. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* timer_ptr Pointer to timer control block */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* TX_SUCCESS Always returns success */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* None */ 59 /* */ 60 /* CALLED BY */ 61 /* */ 62 /* _tx_thread_system_resume Thread resume function */ 63 /* _tx_timer_thread_entry Timer thread processing */ 64 /* */ 65 /* RELEASE HISTORY */ 66 /* */ 67 /* DATE NAME DESCRIPTION */ 68 /* */ 69 /* 05-19-2020 William E. Lamie Initial Version 6.0 */ 70 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 71 /* resulting in version 6.1 */ 72 /* */ 73 /**************************************************************************/ _tx_timer_system_deactivate(TX_TIMER_INTERNAL * timer_ptr)74VOID _tx_timer_system_deactivate(TX_TIMER_INTERNAL *timer_ptr) 75 { 76 77 TX_TIMER_INTERNAL **list_head; 78 TX_TIMER_INTERNAL *next_timer; 79 TX_TIMER_INTERNAL *previous_timer; 80 81 82 /* Pickup the list head pointer. */ 83 list_head = timer_ptr -> tx_timer_internal_list_head; 84 85 /* Determine if the timer still needs deactivation. */ 86 if (list_head != TX_NULL) 87 { 88 89 /* Deactivate the timer. */ 90 91 /* Pickup the next active timer. */ 92 next_timer = timer_ptr -> tx_timer_internal_active_next; 93 94 /* See if this is the only timer in the list. */ 95 if (timer_ptr == next_timer) 96 { 97 98 /* Yes, the only timer on the list. */ 99 100 /* Determine if the head pointer needs to be updated. */ 101 if (*(list_head) == timer_ptr) 102 { 103 104 /* Update the head pointer. */ 105 *(list_head) = TX_NULL; 106 } 107 } 108 else 109 { 110 111 /* At least one more timer is on the same expiration list. */ 112 113 /* Update the links of the adjacent timers. */ 114 previous_timer = timer_ptr -> tx_timer_internal_active_previous; 115 next_timer -> tx_timer_internal_active_previous = previous_timer; 116 previous_timer -> tx_timer_internal_active_next = next_timer; 117 118 /* Determine if the head pointer needs to be updated. */ 119 if (*(list_head) == timer_ptr) 120 { 121 122 /* Update the next timer in the list with the list head pointer. */ 123 next_timer -> tx_timer_internal_list_head = list_head; 124 125 /* Update the head pointer. */ 126 *(list_head) = next_timer; 127 } 128 } 129 130 /* Clear the timer's list head pointer. */ 131 timer_ptr -> tx_timer_internal_list_head = TX_NULL; 132 } 133 } 134 135