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_setinheritsched PORTABLE C */
33 /* 6.1.7 */
34 /* AUTHOR */
35 /* */
36 /* William E. Lamie, Microsoft Corporation */
37 /* */
38 /* DESCRIPTION */
39 /* */
40 /* This function sets the inheritsched attribute from the thread */
41 /* attributes object specified.The inheritsched attribute will be one */
42 /* of PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED. */
43 /* The default inheritsched attribute is PTHREAD_EXPLICIT_SCHED, */
44 /* with a default priority of 0. */
45 /* Use the inheritsched parameter to inherit or explicitly specify the */
46 /* scheduling attributes when creating new threads. */
47 /* */
48 /* */
49 /* INPUT */
50 /* */
51 /* attr Address of the thread attributes */
52 /* inheritsched inheritsched attribute to set */
53 /* */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* 0 if successful */
58 /* Value in case of any error */
59 /* */
60 /* CALLS */
61 /* */
62 /* None */
63 /* */
64 /* CALLED BY */
65 /* */
66 /* Application Code */
67 /* */
68 /* RELEASE HISTORY */
69 /* */
70 /* DATE NAME DESCRIPTION */
71 /* */
72 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
73 /* */
74 /**************************************************************************/
pthread_attr_setinheritsched(pthread_attr_t * attr,INT inheritsched)75 INT pthread_attr_setinheritsched(pthread_attr_t *attr, INT inheritsched)
76 {
77 /* First check the attribute object is already destroyed? */
78 if (attr->inuse == TX_FALSE)
79 {
80 posix_errno = EINVAL;
81 posix_set_pthread_errno(EINVAL);
82 return(EINVAL);
83 }
84 else
85 {
86 attr->inherit_sched = inheritsched ;
87 return(OK);
88 }
89 }
90