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 /** USBX Component */
17 /** */
18 /** Utility */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29
30
31 #if !defined(UX_STANDALONE)
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_utility_semaphore_get PORTABLE C */
37 /* 6.1.11 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function gets a semaphore signal. */
45 /* */
46 /* INPUT */
47 /* */
48 /* semaphore Semaphore to get signal from */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* Completion Status */
53 /* */
54 /* CALLS */
55 /* */
56 /* tx_thread_identify ThreadX identify thread */
57 /* tx_thread_info_get ThreadX get thread info */
58 /* tx_semaphore_get ThreadX semaphore get */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* USBX Components */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
69 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
70 /* used UX prefix to refer to */
71 /* TX symbols instead of using */
72 /* them directly, */
73 /* resulting in version 6.1 */
74 /* 04-25-2022 Chaoqiong Xiao Modified comment(s), */
75 /* off in standalone build, */
76 /* resulting in version 6.1.11 */
77 /* */
78 /**************************************************************************/
_ux_utility_semaphore_get(UX_SEMAPHORE * semaphore,ULONG semaphore_signal)79 UINT _ux_utility_semaphore_get(UX_SEMAPHORE *semaphore, ULONG semaphore_signal)
80 {
81
82 UINT status;
83 UX_THREAD *my_thread;
84 CHAR *name;
85 UINT state;
86 ULONG run_count;
87 UINT priority;
88 UINT preemption_threshold;
89 ULONG time_slice;
90 UX_THREAD *next_thread;
91 UX_THREAD *suspended_thread;
92
93 /* Call TX to know my own tread. */
94 my_thread = tx_thread_identify();
95
96 /* Retrieve information about the previously created thread "my_thread." */
97 tx_thread_info_get(my_thread, &name, &state, &run_count,
98 &priority, &preemption_threshold,
99 &time_slice, &next_thread,&suspended_thread);
100
101 /* Is this the lowest priority thread in the system trying to use TX services ? */
102 if (priority > _ux_system -> ux_system_thread_lowest_priority)
103 {
104
105 /* We need to remember this thread priority. */
106 _ux_system -> ux_system_thread_lowest_priority = priority;
107
108 }
109
110 /* Get ThreadX semaphore instance. */
111 status = tx_semaphore_get(semaphore, semaphore_signal);
112
113 /* Return completion status. */
114 return(status);
115 }
116 #endif
117