1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** USBX Component */ 16 /** */ 17 /** Utility */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /* Include necessary system files. */ 24 25 #define UX_SOURCE_CODE 26 27 #include "ux_api.h" 28 29 30 #if !defined(UX_STANDALONE) 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _ux_utility_thread_schedule_other PORTABLE C */ 36 /* 6.1.11 */ 37 /* AUTHOR */ 38 /* */ 39 /* Chaoqiong Xiao, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function force the scheduling of all other threads. */ 44 /* */ 45 /* INPUT */ 46 /* */ 47 /* caller_priority Priority to restore. */ 48 /* */ 49 /* OUTPUT */ 50 /* */ 51 /* Completion Status */ 52 /* */ 53 /* CALLS */ 54 /* */ 55 /* tx_thread_identify ThreadX identify */ 56 /* tx_thread_priority_change ThreadX priority change */ 57 /* tx_thread_relinquish ThreadX relinquish */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* USBX Components */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 68 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 69 /* used UX prefix to refer to */ 70 /* TX symbols instead of using */ 71 /* them directly, */ 72 /* resulting in version 6.1 */ 73 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */ 74 /* off in standalone build, */ 75 /* resulting in version 6.1.11 */ 76 /* */ 77 /**************************************************************************/ _ux_utility_thread_schedule_other(UINT caller_priority)78UINT _ux_utility_thread_schedule_other(UINT caller_priority) 79 { 80 81 UINT status; 82 UINT old_priority; 83 UX_THREAD *my_thread; 84 85 UX_PARAMETER_NOT_USED(caller_priority); 86 87 /* Call TX to know my own tread. */ 88 my_thread = tx_thread_identify(); 89 90 /* Call ThreadX to change thread priority . */ 91 status = tx_thread_priority_change(my_thread, _ux_system -> ux_system_thread_lowest_priority, &old_priority); 92 93 /* Check for error. */ 94 if (status == TX_SUCCESS) 95 { 96 97 /* Wait until all other threads passed into the scheduler. */ 98 _ux_utility_thread_relinquish(); 99 100 /* And now return the priority of the thread to normal. */ 101 status = tx_thread_priority_change(my_thread, old_priority, &old_priority); 102 103 } 104 105 /* Return completion status. */ 106 return(status); 107 } 108 #endif 109