]> rtime.felk.cvut.cz Git - frescor/fwp.git/blob - frsh_aquosa/mngr/frsh_service_th.h
c68bce94bfd4ba25b30d2cdb8b9098b52e7dd27e
[frescor/fwp.git] / frsh_aquosa / mngr / frsh_service_th.h
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. Politécnica  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 //
24 //  based on previous work (FSF) done in the FIRST project
25 //                       
26 //   Copyright (C) 2005  Mälardalen University, SWEDEN
27 //                       Scuola Superiore S.Anna, ITALY
28 //                       Universidad de Cantabria, SPAIN
29 //                       University of York, UK
30 //
31 //   FSF API web pages: http://marte.unican.es/fsf/docs
32 //                      http://shark.sssup.it/contrib/first/docs/
33 //
34 //  This file is part of FRSH Implementation
35 //
36 //  FRSH API is free software; you can  redistribute it and/or  modify
37 //  it under the terms of  the GNU General Public License as published by
38 //  the Free Software Foundation;  either  version 2, or (at  your option)
39 //  any later version.
40 //
41 //  FRSH API  is distributed  in  the hope  that  it  will  be useful,  but
42 //  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
43 //  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
44 //  General Public License for more details.
45 //
46 //  You should have  received a  copy of  the  GNU  General Public License
47 //  distributed  with  FRSH API;  see file COPYING.   If not,  write to the
48 //  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
49 //  02111-1307, USA.
50 //
51 //  As a special exception, if you include this header file into source
52 //  files to be compiled, this header file does not by itself cause
53 //  the resulting executable to be covered by the GNU General Public
54 //  License.  This exception does not however invalidate any other
55 //  reasons why the executable file might be covered by the GNU General
56 //  Public License.
57 // -----------------------------------------------------------------------
58 //==============================================
59 //  ******** *******    ********  **      **
60 //  **///// /**////**  **//////  /**     /**
61 //  **      /**   /** /**        /**     /**
62 //  ******* /*******  /********* /**********
63 //  **////  /**///**  ////////** /**//////**
64 //  **      /**  //**        /** /**     /**
65 //  **      /**   //** ********  /**     /**
66 //  //       //     // ////////   //      // 
67 //
68 // FRSH(FRescor ScHeduler), pronounced "fresh"
69 //==============================================
70
71 #ifndef FRSH_SERVICE_TH_H_
72 #define FRSH_SERVICE_TH_H_
73
74 /*
75  * frsh_service_th.h
76  *
77  * This file contains the types, functions, macro and constants
78  * declaration exported in order of makeing the service thread
79  * reachable and accessible from the other part of the API, and
80  * so from the normal process and threads requesting its services.
81  *
82  * All API source file and/or module that need communication with the
83  * service thread need to include this header.
84  *
85  * Note the service thread "sub-API" is quite frugal, since it's made up
86  * of only one function ('frsh_service_th_ask_for()', plus
87  * 'frsh_service_th_init()' only for initialization)
88  */
89
90 /*******************/
91 /* I N C L U D E S */
92 /*******************/
93
94 #include "frsh_internal_msg.h"
95
96 /*******************************************/
97 /* C O N S T A N T S   A N D   M A C R O S */
98 /*******************************************/
99
100 /* some beautifying constants
101  * (not sure this is the best place for them but...) */
102 #define FRSH_NOT_VALID_THREAD_ID        -1
103 #define FRSH_NOT_VALID_VRES_ID          -1
104 #define FRSH_QRES_NOT_VALID_SID         -1
105 #define FRSH_QRES_BACKGROUND_SID        -5
106
107 #define FRSH_QRES_NOT_VALID_DISK        -1
108 #define FRSH_QRES_BACKGROUND_DISK       -5
109
110 /* service thread specific error codes and error handling */
111 #define FRSH_SERVICE_TH_NO_ERROR                0
112
113 #define FRSH_SERVICE_TH_ERR_BASE_VALUE          0x02040800
114
115 #define FRSH_SERVICE_TH_ERR_SERVER              0x02040801
116 #define FRSH_SERVICE_TH_ERR_SOCKET              0x02040802
117 #define FRSH_SERVICE_TH_ERR_COMMAND             0x02040803
118 #define FRSH_SERVICE_TH_ERR_LABEL               0x02040804
119
120 #define FRSH_SERVICE_TH_ERR_LAST_VALUE          0x02040805
121
122 #define check_service_th_error(x)                       \
123  ( x != FRSH_SERVICE_TH_NO_ERROR &&                     \
124   ( x <= FRSH_SERVICE_TH_ERR_BASE_VALUE                 \
125   || x >= FRSH_SERVICE_TH_ERR_LAST_VALUE) ? 0 : 1 )
126
127 /***************************************/
128 /* S E R V I C E   T H R E A D   A P I */
129 /***************************************/
130
131 /* service thread initialization */
132 int frsh_service_th_init(pid_t *pid_key);
133
134 /* request for some service to the service thread */
135 int frsh_service_th_ask_for(const pid_t pid_key,
136         const frsh_in_msg_t *msg_in,
137         frsh_out_msg_t *msg_out);
138
139 #endif          /* FRSH_SERVICE_TH_H_ */