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 /** Mutex */
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_mutex.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _txe_mutex_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 mutex information get */
44 /* service. */
45 /* */
46 /* INPUT */
47 /* */
48 /* mutex_ptr Pointer to mutex control block */
49 /* name Destination for the mutex name */
50 /* count Destination for the owner count */
51 /* owner Destination for the owner's */
52 /* thread control block pointer */
53 /* first_suspended Destination for pointer of first */
54 /* thread suspended on the mutex */
55 /* suspended_count Destination for suspended count */
56 /* next_mutex Destination for pointer to next */
57 /* mutex on the created list */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* TX_MUTEX_ERROR Invalid mutex pointer */
62 /* status Completion status */
63 /* */
64 /* CALLS */
65 /* */
66 /* _tx_mutex_info_get Actual mutex info get service */
67 /* */
68 /* CALLED BY */
69 /* */
70 /* Application Code */
71 /* */
72 /* RELEASE HISTORY */
73 /* */
74 /* DATE NAME DESCRIPTION */
75 /* */
76 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
77 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
78 /* resulting in version 6.1 */
79 /* */
80 /**************************************************************************/
_txe_mutex_info_get(TX_MUTEX * mutex_ptr,CHAR ** name,ULONG * count,TX_THREAD ** owner,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_MUTEX ** next_mutex)81 UINT _txe_mutex_info_get(TX_MUTEX *mutex_ptr, CHAR **name, ULONG *count, TX_THREAD **owner,
82 TX_THREAD **first_suspended, ULONG *suspended_count,
83 TX_MUTEX **next_mutex)
84 {
85
86 UINT status;
87
88
89 /* Check for an invalid mutex pointer. */
90 if (mutex_ptr == TX_NULL)
91 {
92
93 /* Mutex pointer is invalid, return appropriate error code. */
94 status = TX_MUTEX_ERROR;
95 }
96
97 /* Now check for invalid mutex ID. */
98 else if (mutex_ptr -> tx_mutex_id != TX_MUTEX_ID)
99 {
100
101 /* Mutex pointer is invalid, return appropriate error code. */
102 status = TX_MUTEX_ERROR;
103 }
104 else
105 {
106
107 /* Otherwise, call the actual mutex information get service. */
108 status = _tx_mutex_info_get(mutex_ptr, name, count, owner, first_suspended,
109 suspended_count, next_mutex);
110 }
111
112 /* Return completion status. */
113 return(status);
114 }
115
116