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 /** POSIX wrapper for THREADX */
16 /** */
17 /** */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 /* Include necessary system files. */
23
24 #include "tx_api.h" /* Threadx API */
25 #include "pthread.h" /* Posix API */
26 #include "px_int.h" /* Posix helper functions */
27
28
29 /**************************************************************************/
30 /* */
31 /* FUNCTION RELEASE */
32 /* */
33 /* pthread_exit PORTABLE C */
34 /* 6.1.7 */
35 /* AUTHOR */
36 /* */
37 /* William E. Lamie, Microsoft Corporation */
38 /* */
39 /* DESCRIPTION */
40 /* */
41 /* */
42 /* The pthread_exit() function terminates the calling thread, making */
43 /* its exit status available to any waiting threads.Normally,a thread */
44 /* terminates by returning from the start routine that was specified */
45 /* in the pthread_create() call which started it. */
46 /* An implicit call to pthread_exit() occurs when any thread returns */
47 /* from its start routine. (With the exception of the initial thread, */
48 /* at which time an implicit call to exit() occurs). */
49 /* The pthread_exit() function provides an interface similar to exit()*/
50 /* but on a per-thread basis. */
51 /* */
52 /* pthread_exit() does not return. */
53 /* */
54 /* */
55 /* INPUT */
56 /* value_ptr exit parameter */
57 /* */
58 /* OUTPUT */
59 /* */
60 /* none pthread_exit() does not return. */
61 /* */
62 /* CALLS */
63 /* */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application Code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
74 /* */
75 /**************************************************************************/
pthread_exit(void * value_ptr)76 VOID pthread_exit(void *value_ptr)
77 {
78
79 TX_THREAD *thread_ptr;
80 POSIX_TCB *pthread_ptr;
81
82 /* Get the thread identifier of the currently running thread */
83 thread_ptr = tx_thread_identify();
84 /* get posix TCB for this pthread */
85 pthread_ptr = (POSIX_TCB *)thread_ptr;
86
87 /* Signal the housekeeping ThreadX thread to delete the requested pthread */
88 posix_destroy_pthread(pthread_ptr,value_ptr);
89
90 /* Indicate success. */
91 return;
92
93 }
94