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_yield PORTABLE C */
35 /* 6.1.7 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This subroutine forces the calling thread to relinquish use of its */
43 /* processor,and to wait in the run queue before it is scheduled again.*/
44 /* If the run queue is empty when this subroutine is called, the */
45 /* calling thread is immediately rescheduled. */
46 /* */
47 /* INPUT */
48 /* */
49 /* Nothing */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* None */
54 /* */
55 /* CALLS */
56 /* */
57 /* posix_internal_error posix internal error function */
58 /* tx_thread_relinquish ThreadX function */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application Code */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
69 /* */
70 /**************************************************************************/
pthread_yield(VOID)71 VOID pthread_yield(VOID)
72 {
73 /* Make sure we're calling this routine from a thread context. */
74 if (!posix_in_thread_context())
75 {
76 /* return POSIX error. */
77 posix_internal_error(444);
78 }
79
80 /* This relinquishes the CPU. */
81 tx_thread_relinquish();
82 }
83