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 #define TX_THREAD_SMP_SOURCE_CODE 25 26 27 /* Include necessary system files. */ 28 29 #include "tx_api.h" 30 #include "tx_timer.h" 31 #include "tx_thread.h" 32 33 34 /**************************************************************************/ 35 /* */ 36 /* FUNCTION RELEASE */ 37 /* */ 38 /* _tx_timer_interrupt SMP/Linux/GCC */ 39 /* 6.1 */ 40 /* AUTHOR */ 41 /* */ 42 /* William E. Lamie, Microsoft Corporation */ 43 /* */ 44 /* DESCRIPTION */ 45 /* */ 46 /* This function processes the hardware timer interrupt. This */ 47 /* processing includes incrementing the system clock and checking for */ 48 /* time slice and/or timer expiration. If either is found, the */ 49 /* interrupt context save/restore functions are called along with the */ 50 /* expiration functions. */ 51 /* */ 52 /* INPUT */ 53 /* */ 54 /* None */ 55 /* */ 56 /* OUTPUT */ 57 /* */ 58 /* None */ 59 /* */ 60 /* CALLS */ 61 /* */ 62 /* _tx_linux_debug_entry_insert */ 63 /* _tx_timer_expiration_process */ 64 /* _tx_thread_time_slice */ 65 /* */ 66 /* CALLED BY */ 67 /* */ 68 /* interrupt vector */ 69 /* */ 70 /* RELEASE HISTORY */ 71 /* */ 72 /* DATE NAME DESCRIPTION */ 73 /* */ 74 /* 09-30-2020 William E. Lamie Initial Version 6.1 */ 75 /* */ 76 /**************************************************************************/ _tx_timer_interrupt(VOID)77VOID _tx_timer_interrupt(VOID) 78 { 79 80 UINT saved_posture; 81 82 83 /* Get the protection. */ 84 saved_posture = _tx_thread_smp_protect(); 85 86 /* Increment the system active counter. */ 87 _tx_timer_interrupt_active++; 88 89 /* Debug entry. */ 90 _tx_linux_debug_entry_insert("TIMER INTERRUPT", __FILE__, __LINE__); 91 92 /* Increment the system clock. */ 93 _tx_timer_system_clock++; 94 95 /* Test for timer expiration. */ 96 if (*_tx_timer_current_ptr) 97 { 98 99 /* Set expiration flag. */ 100 _tx_timer_expired = TX_TRUE; 101 } 102 else 103 { 104 105 /* No timer expired, increment the timer pointer. */ 106 _tx_timer_current_ptr++; 107 108 /* Check for wrap-around. */ 109 if (_tx_timer_current_ptr == _tx_timer_list_end) 110 { 111 112 /* Wrap to beginning of list. */ 113 _tx_timer_current_ptr = _tx_timer_list_start; 114 } 115 } 116 117 /* See if anything has expired. */ 118 if (_tx_timer_expired) 119 { 120 121 /* Did a timer expire? */ 122 if (_tx_timer_expired) 123 { 124 125 /* Process timer expiration. */ 126 _tx_timer_expiration_process(); 127 } 128 } 129 130 /* Call time-slice processing to process time-slice for all threads on each core. */ 131 _tx_thread_time_slice(); 132 133 /* Increment the system active counter. */ 134 _tx_timer_interrupt_active++; 135 136 /* Release the protection. */ 137 _tx_thread_smp_unprotect(saved_posture); 138 } 139