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"
57 /*************************
59 *************************/
62 * frsh_thread_attr_init()
64 * Initialize a thread attributes object
66 * This function initializes the object pointed to by attr to all
67 * the default values defined by FRSH
69 * @return 0 if successful; otherwise it returns \n
70 * FOSA_ENOMEM: insufficient memory exists to initialize the thread
73 int frsh_thread_attr_init(frsh_thread_attr_t *attr)
77 ret_value=pthread_attr_init(attr);
78 /* if (ret_value==0) {
79 // set the default values
80 detachstate = detached thread (no join operation allowed)
81 CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
82 // inheritsched = explicit, so that we can explicitly set the attributes
83 CHK(pthread_attr_setinheritsched(attr,PTHREAD_EXPLICIT_SCHED));
84 // schedpolicy = fixed priorities
85 CHK(pthread_attr_setschedpolicy(attr,SCHED_FIFO));
86 // detachstate = detached thread (no join operation allowed)
87 CHK(pthread_attr_setdetachstate(attr,PTHREAD_CREATE_DETACHED));
94 * frsh_thread_attr_destroy()
96 * Destroy a thread attributes object
98 * This function is used to destroy the thread attributes object,
99 * pointed to by attr, and deallocate any system resources allocated for it
103 int frsh_thread_attr_destroy(frsh_thread_attr_t *attr)
105 return pthread_attr_destroy(attr);
109 * frsh_thread_attr_set_stacksize()
111 * Set the thread minimum stack size in a thread attributes object
113 * This function sets the minimum stack size of the thread attributes
114 * object attr to the value given by stacksize, in bytes. This
115 * function has no runtime effect on the stack size, except when the
116 * attributes object is used to create a thread, when it will be
117 * created with the specified minimum stack size
119 * @return 0 if successful, or the following error code:
120 * FOSA_EINVAL: the specified stacksize value is not supported in
121 * this implementation
123 int frsh_thread_attr_set_stacksize(frsh_thread_attr_t *attr,
126 return pthread_attr_setstacksize(attr,stacksize);
130 * frsh_thread_attr_get_stacksize()
132 * Get the thread minimum stack size from a thread attributes object
134 * This function sets the variable pointed to by stacksize to the
135 * minimum stack size stored in the thread attributes object attr.
139 int frsh_thread_attr_get_stacksize(const frsh_thread_attr_t *attr,
142 return pthread_attr_getstacksize(attr,stacksize);