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