1 // -----------------------------------------------------------------------
2 // Copyright (C) 2006 - 2007 FRESCOR consortium partners:
4 // Universidad de Cantabria, SPAIN
5 // University of York, UK
6 // Scuola Superiore Sant'Anna, ITALY
7 // Kaiserslautern University, GERMANY
8 // Univ. Politecnica Valencia, SPAIN
9 // Czech Technical University in Prague, CZECH REPUBLIC
11 // Thales Communication S.A. FRANCE
12 // Visual Tools S.A. SPAIN
13 // Rapita Systems Ltd UK
16 // See http://www.frescor.org for a link to partners' websites
18 // FRESCOR project (FP6/2005/IST/5-034026) is funded
19 // in part by the European Union Sixth Framework Programme
20 // The European Union is not liable of any use that may be
23 // This file is part of the FRSH implementation
25 // FRSH is free software; you can redistribute it and/or modify
26 // it under the terms of the GNU General Public License as published by
27 // the Free Software Foundation; either version 2, or (at your option)
30 // FRSH is distributed in the hope that it will be useful, but
31 // WITHOUT ANY WARRANTY; without even the implied warranty of
32 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 // General Public License for more details.
35 // You should have received a copy of the GNU General Public License
36 // distributed with FRSH; see file COPYING. If not, write to the
37 // Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
40 // -----------------------------------------------------------------------
42 //==============================================
43 // ******** ****** ******** **********
44 // **///// /** ** **////// /** /**
45 // ** /** ** /** /** /**
46 // ******* /** ** /********* /**********
47 // **//// /** ** ////////** /**//////**
48 // ** /** ** /** /** /**
49 // ** /** ** ******** /** /**
50 // // /******/ //////// // //
52 // FOSA(Frescor Operating System Adaptation layer)
53 //================================================
55 #include "frsh_fosa.h"
59 /*************************
61 *************************/
64 * frsh_thread_attr_init()
66 * Initialize a thread attributes object
68 * This function initializes the object pointed to by attr to all
69 * the default values defined by FRSH
71 * @return 0 if successful; otherwise it returns \n
72 * FOSA_ENOMEM: insufficient memory exists to initialize the thread
75 int frsh_thread_attr_init(frsh_thread_attr_t *attr)
79 ret_value=pthread_attr_init(attr);
80 /* if (ret_value==0) {
81 // set the default values
82 detachstate = detached thread (no join operation allowed)
83 CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
84 // inheritsched = explicit, so that we can explicitly set the attributes
85 CHK(pthread_attr_setinheritsched(attr,PTHREAD_EXPLICIT_SCHED));
86 // schedpolicy = fixed priorities
87 CHK(pthread_attr_setschedpolicy(attr,SCHED_FIFO));
88 // detachstate = detached thread (no join operation allowed)
89 CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
96 * frsh_thread_attr_destroy()
98 * Destroy a thread attributes object
100 * This function is used to destroy the thread attributes object,
101 * pointed to by attr, and deallocate any system resources allocated for it
105 int frsh_thread_attr_destroy(frsh_thread_attr_t *attr)
107 return pthread_attr_destroy(attr);
111 * frsh_thread_attr_set_stacksize()
113 * Set the thread minimum stack size in a thread attributes object
115 * This function sets the minimum stack size of the thread attributes
116 * object attr to the value given by stacksize, in bytes. This
117 * function has no runtime effect on the stack size, except when the
118 * attributes object is used to create a thread, when it will be
119 * created with the specified minimum stack size
121 * @return 0 if successful, or the following error code:
122 * FOSA_EINVAL: the specified stacksize value is not supported in
123 * this implementation
125 int frsh_thread_attr_set_stacksize(frsh_thread_attr_t *attr,
128 return pthread_attr_setstacksize(attr,stacksize);
132 * frsh_thread_attr_get_stacksize()
134 * Get the thread minimum stack size from a thread attributes object
136 * This function sets the variable pointed to by stacksize to the
137 * minimum stack size stored in the thread attributes object attr.
141 int frsh_thread_attr_get_stacksize(const frsh_thread_attr_t *attr,
144 return pthread_attr_getstacksize(attr,stacksize);