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 /* FUNCTION RELEASE */
31 /* */
32 /* pthread_attr_getschedpolicy PORTABLE C */
33 /* 6.1.7 */
34 /* AUTHOR */
35 /* */
36 /* William E. Lamie, Microsoft Corporation */
37 /* */
38 /* DESCRIPTION */
39 /* */
40 /* This function returns the scheduling policy from the pthread */
41 /* attributes object. */
42 /* */
43 /* */
44 /* INPUT */
45 /* */
46 /* attr Address of the thread attributes */
47 /* policy Address of variable to contain the */
48 /* returned scheduling policy */
49 /* */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* 0 if successful */
54 /* Value in case of any error */
55 /* */
56 /* CALLS */
57 /* */
58 /* None */
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_attr_getschedpolicy(pthread_attr_t * attr,INT * policy)71 INT pthread_attr_getschedpolicy(pthread_attr_t *attr, INT *policy)
72 {
73 /* First check the attribute object is already destroyed? */
74 if (attr->inuse == TX_FALSE)
75 {
76 posix_errno = EINVAL;
77 posix_set_pthread_errno(EINVAL);
78 return(EINVAL);
79 }
80 else
81 {
82 *policy = attr->sched_policy;
83 return(OK);
84 }
85 }
86
87
88