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