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