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 /**   Thread                                                              */
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_thread.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _txe_thread_info_get                                PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function checks for errors in the thread information get       */
45 /*    service.                                                            */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    thread_ptr                        Pointer to thread control block   */
50 /*    name                              Destination for the thread name   */
51 /*    state                             Destination for thread state      */
52 /*    run_count                         Destination for thread run count  */
53 /*    priority                          Destination for thread priority   */
54 /*    preemption_threshold              Destination for thread preemption-*/
55 /*                                        threshold                       */
56 /*    time_slice                        Destination for thread time-slice */
57 /*    next_thread                       Destination for next created      */
58 /*                                        thread                          */
59 /*    next_suspended_thread             Destination for next suspended    */
60 /*                                        thread                          */
61 /*                                                                        */
62 /*  OUTPUT                                                                */
63 /*                                                                        */
64 /*    TX_THREAD_ERROR                   Invalid thread pointer            */
65 /*    status                            Completion status                 */
66 /*                                                                        */
67 /*  CALLS                                                                 */
68 /*                                                                        */
69 /*    _tx_thread_info_get               Actual thread information get     */
70 /*                                        service                         */
71 /*                                                                        */
72 /*  CALLED BY                                                             */
73 /*                                                                        */
74 /*    Application Code                                                    */
75 /*                                                                        */
76 /*  RELEASE HISTORY                                                       */
77 /*                                                                        */
78 /*    DATE              NAME                      DESCRIPTION             */
79 /*                                                                        */
80 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
81 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
82 /*                                            resulting in version 6.1    */
83 /*                                                                        */
84 /**************************************************************************/
_txe_thread_info_get(TX_THREAD * thread_ptr,CHAR ** name,UINT * state,ULONG * run_count,UINT * priority,UINT * preemption_threshold,ULONG * time_slice,TX_THREAD ** next_thread,TX_THREAD ** next_suspended_thread)85 UINT  _txe_thread_info_get(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count,
86                 UINT *priority, UINT *preemption_threshold, ULONG *time_slice,
87                 TX_THREAD **next_thread, TX_THREAD **next_suspended_thread)
88 {
89 
90 UINT    status;
91 
92 
93     /* Check for an invalid thread pointer.  */
94     if (thread_ptr == TX_NULL)
95     {
96 
97         /* Thread pointer is invalid, return appropriate error code.  */
98         status =  TX_THREAD_ERROR;
99     }
100 
101     /* Now check for invalid thread ID.  */
102     else if (thread_ptr -> tx_thread_id != TX_THREAD_ID)
103     {
104 
105         /* Thread pointer is invalid, return appropriate error code.  */
106         status =  TX_THREAD_ERROR;
107     }
108     else
109     {
110 
111         /* Call the actual thread information get service.  */
112         status =  _tx_thread_info_get(thread_ptr, name, state, run_count, priority, preemption_threshold,
113                             time_slice, next_thread, next_suspended_thread);
114     }
115 
116     /* Return completion status.  */
117     return(status);
118 }
119 
120