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_delete 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 delete function call. */
45 /* */
46 /* INPUT */
47 /* */
48 /* thread_ptr Pointer to thread to suspend */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* TX_THREAD_ERROR Invalid thread pointer */
53 /* TX_CALLER_ERROR Invalid caller of function */
54 /* status Actual completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* _tx_thread_delete Actual thread delete function */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application code */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
69 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
70 /* resulting in version 6.1 */
71 /* */
72 /**************************************************************************/
_txe_thread_delete(TX_THREAD * thread_ptr)73 UINT _txe_thread_delete(TX_THREAD *thread_ptr)
74 {
75
76 UINT status;
77
78
79 /* Check for invalid caller of this function. */
80 if (TX_THREAD_GET_SYSTEM_STATE() != ((ULONG) 0))
81 {
82
83 /* Invalid caller of this function, return appropriate error code. */
84 status = TX_CALLER_ERROR;
85 }
86
87 /* Check for an invalid thread pointer. */
88 else if (thread_ptr == TX_NULL)
89 {
90
91 /* Thread pointer is invalid, return appropriate error code. */
92 status = TX_THREAD_ERROR;
93 }
94
95 /* Now check for invalid thread ID. */
96 else if (thread_ptr -> tx_thread_id != TX_THREAD_ID)
97 {
98
99 /* Thread pointer is invalid, return appropriate error code. */
100 status = TX_THREAD_ERROR;
101 }
102 else
103 {
104
105 /* Call actual thread delete function. */
106 status = _tx_thread_delete(thread_ptr);
107 }
108
109 /* Return completion status. */
110 return(status);
111 }
112
113