]> rtime.felk.cvut.cz Git - frescor/fosa.git/blob - src_aquosa/frsh_fosa.c
Additions to fosa time to be used with FRSH
[frescor/fosa.git] / src_aquosa / frsh_fosa.c
1 // -----------------------------------------------------------------------
2 //  Copyright (C) 2006 - 2007 FRESCOR consortium partners:
3 //
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
10 //    ENEA                                   SWEDEN
11 //    Thales Communication S.A.              FRANCE
12 //    Visual Tools S.A.                      SPAIN
13 //    Rapita Systems Ltd                     UK
14 //    Evidence                               ITALY
15 //    
16 //    See http://www.frescor.org for a link to partners' websites
17 //
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
21 //        made of this code.
22 //
23 //  This file is part of the FRSH implementation
24 //
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)
28 //  any later version.
29 //
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.
34 //
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
38 //  02111-1307, USA.
39 //
40 // -----------------------------------------------------------------------
41 //frsh_fosa.c
42 //==============================================
43 //  ********  ******    ********  **********
44 //  **///// /**    **  **//////  /**     /**
45 //  **      /**    ** /**        /**     /**
46 //  ******* /**    ** /********* /**********
47 //  **////  /**    ** ////////** /**//////**
48 //  **      /**    **        /** /**     /**
49 //  **      /**    **  ********  /**     /**
50 //  //       /******/  ////////   //      // 
51 //
52 // FOSA(Frescor Operating System Adaptation layer)
53 //================================================
54
55 #include "frsh_fosa.h"
56
57 /*************************
58  * Thread attributes
59  *************************/ 
60
61 /**
62  * frsh_thread_attr_init()
63  *
64  * Initialize a thread attributes object
65  *
66  * This function initializes the object pointed to by attr to all 
67  * the default values defined by FRSH
68  *
69  * @return 0 if successful; otherwise it returns \n
70  *   FOSA_ENOMEM: insufficient memory exists to initialize the thread 
71  *           attributes object
72  **/
73 int frsh_thread_attr_init(frsh_thread_attr_t *attr)
74 {
75         int ret_value;
76
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));
88         } */
89
90         return ret_value;
91 }
92
93 /**
94  * frsh_thread_attr_destroy()
95  *
96  * Destroy a thread attributes object
97  *
98  * This function is used to destroy the thread attributes object,
99  * pointed to by attr, and deallocate any system resources allocated for it
100  * 
101  * Returns 0
102  */
103 int frsh_thread_attr_destroy(frsh_thread_attr_t *attr)
104 {
105         return pthread_attr_destroy(attr);
106 }
107
108 /**
109  * frsh_thread_attr_set_stacksize()
110  *
111  * Set the thread minimum stack size in a thread attributes object
112  *
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
118  * 
119  * @return 0 if successful, or the following error code:
120  *    FOSA_EINVAL: the specified stacksize  value is not supported in
121  *            this implementation
122  */
123 int frsh_thread_attr_set_stacksize(frsh_thread_attr_t *attr,
124         size_t stacksize)
125 {
126         return pthread_attr_setstacksize(attr,stacksize);
127 }
128
129 /**
130  * frsh_thread_attr_get_stacksize()
131  *
132  * Get the thread minimum stack size from a thread attributes object
133  *
134  * This function sets the variable pointed to by stacksize to the
135  * minimum stack size stored in the thread attributes object attr.
136  * 
137  * @return 0
138  */
139 int frsh_thread_attr_get_stacksize(const frsh_thread_attr_t *attr,
140         size_t *stacksize)
141 {
142         return pthread_attr_getstacksize(attr,stacksize);
143 }
144