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