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_getschedparam PORTABLE C */
35 /* 6.1.7 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function returns the scheduling parameters attribute from the */
43 /* pthread TCB. */
44 /* */
45 /* */
46 /* INPUT */
47 /* */
48 /* thread POSIX thread ID */
49 /* policy Address of the scheduling policy */
50 /* sched_param Address of structure to contain the */
51 /* returned scheduling parameters */
52 /* */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* 0 if successful */
57 /* Value in case of any error */
58 /* */
59 /* CALLS */
60 /* */
61 /* None */
62 /* */
63 /* CALLED BY */
64 /* */
65 /* Application Code */
66 /* */
67 /* RELEASE HISTORY */
68 /* */
69 /* DATE NAME DESCRIPTION */
70 /* */
71 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
72 /* */
73 /**************************************************************************/
pthread_getschedparam(pthread_t thread,INT * policy,struct sched_param * param)74 INT pthread_getschedparam(pthread_t thread, INT *policy, struct sched_param *param)
75 {
76
77 POSIX_TCB *thread_tcb;
78
79
80 thread_tcb=posix_tid2tcb(thread);
81
82 if(thread_tcb==NULL)
83 {
84 return(ESRCH);
85 }
86 else
87 {
88 *policy=thread_tcb->sched_policy;
89 *param=thread_tcb->sched_attr;
90 return(OK);
91 }
92
93 }
94