Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief POSIX Threads Private Support
0007  *
0008  * This include file contains all the private support information for
0009  * POSIX threads.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 1989-2011.
0014  *  On-Line Applications Research Corporation (OAR).
0015  *
0016  * Redistribution and use in source and binary forms, with or without
0017  * modification, are permitted provided that the following conditions
0018  * are met:
0019  * 1. Redistributions of source code must retain the above copyright
0020  *    notice, this list of conditions and the following disclaimer.
0021  * 2. Redistributions in binary form must reproduce the above copyright
0022  *    notice, this list of conditions and the following disclaimer in the
0023  *    documentation and/or other materials provided with the distribution.
0024  *
0025  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0026  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0028  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0029  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0030  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0031  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0033  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0034  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0035  * POSSIBILITY OF SUCH DAMAGE.
0036  */
0037 
0038 #ifndef _RTEMS_POSIX_PTHREADATTRIMPL_H
0039 #define _RTEMS_POSIX_PTHREADATTRIMPL_H
0040 
0041 #include <errno.h>
0042 #include <pthread.h>
0043 
0044 #include <rtems/score/basedefs.h>
0045 #include <rtems/score/assert.h>
0046 #include <rtems/posix/priorityimpl.h>
0047 #include <rtems/posix/threadsup.h>
0048 
0049 #ifdef __cplusplus
0050 extern "C" {
0051 #endif
0052 
0053 /**
0054  * @addtogroup POSIX_PTHREAD
0055  */
0056 /**@{**/
0057 
0058 /**
0059  * This variable contains the default POSIX Thread attributes.
0060  */
0061 extern const pthread_attr_t _POSIX_Threads_Default_attributes;
0062 
0063 static inline void _POSIX_Threads_Copy_attributes(
0064   pthread_attr_t        *dst_attr,
0065   const pthread_attr_t  *src_attr
0066 )
0067 {
0068   *dst_attr = *src_attr;
0069   _Assert(
0070     dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated)
0071   );
0072   dst_attr->affinityset = &dst_attr->affinitysetpreallocated;
0073 }
0074 
0075 static inline void _POSIX_Threads_Initialize_attributes(
0076   pthread_attr_t  *attr
0077 )
0078 {
0079   _POSIX_Threads_Copy_attributes(
0080     attr,
0081     &_POSIX_Threads_Default_attributes
0082   );
0083 }
0084 
0085 static inline void _POSIX_Threads_Get_sched_param_sporadic(
0086   const Thread_Control    *the_thread,
0087   const Scheduler_Control *scheduler,
0088   struct sched_param      *param
0089 )
0090 {
0091 #if defined(RTEMS_POSIX_API)
0092   const POSIX_API_Control *api;
0093 
0094   api = (const POSIX_API_Control*) the_thread->API_Extensions[ THREAD_API_POSIX ];
0095   param->sched_ss_low_priority = _POSIX_Priority_From_core(
0096     scheduler,
0097     api->Sporadic.Low_priority.priority
0098   );
0099   param->sched_ss_repl_period = api->Sporadic.sched_ss_repl_period;
0100   param->sched_ss_init_budget = api->Sporadic.sched_ss_init_budget;
0101   param->sched_ss_max_repl = api->Sporadic.sched_ss_max_repl;
0102 #else
0103   (void) the_thread;
0104   (void) scheduler;
0105   (void) param;
0106 #endif
0107 }
0108 
0109 /** @} */
0110 
0111 #ifdef __cplusplus
0112 }
0113 #endif
0114 
0115 #endif
0116 /*  end of include file */