Subversion Repositories shark

Rev

Rev 929 | Rev 986 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
929 lipari 1
/**
2
   @file Distributed.
3
 */
4
 
899 trimarchi 5
//fsf_distributed.h
6
//=====================================================================
7
//       FFFFFFIII   RRRRR      SSTTTTTTT
8
//      FF         IIR   RR    SS
9
//     FF           IR        SS
10
//    FFFFFF         RRRR    SSSSST
11
//   FF       FI       RRR  SS
12
//  FF         II     RRR  SS
13
// FF           IIIIIR    RS
14
//
15
// FSF(FIRST Scheduling Framework)
16
// distributed services functionality
17
//=====================================================================
18
 
19
#include "fsf_core.h"
20
 
21
#ifndef _FSF_DISTRIBUTED_H_
22
#define _FSF_DISTRIBUTED_H_
23
 
24
#define FSF_DISTRIBUTED_MODULE_SUPPORTED       1
25
 
26
 
929 lipari 27
/**
899 trimarchi 28
 
929 lipari 29
   \ingroup distjmodule
30
 
985 julio 31
   This operation sets the network id attribute in the contract
32
   pointed to by contract, to the value specified by network_id.
33
   When a contract is negotiated, if network_id is FSF_NULL_NETWORK_ID
34
   (which is the default value) the contract is negotiated for the
35
   processing capacity of the node making the call. If network_id
36
   represents a valid network identifier, the negotiation is carried
37
   out for the specified network.
38
 
39
   @param contract          the pointer to the contract object
40
   @param [in] network_id   the network identifier
41
 
42
   @retval 0 if the operation is succesful
43
   @retval FSF_ERR_BAD_ARGUMENT if contract is null or the network
44
     id is not valid.
929 lipari 45
*/
899 trimarchi 46
int
47
fsf_set_contract_network_id
48
  (fsf_contract_parameters_t *contract,
49
   fsf_network_id_t           network_id);
50
 
929 lipari 51
/**
899 trimarchi 52
 
929 lipari 53
   \ingroup distjmodule
985 julio 54
 
55
   This operation puts the network identification
56
   corresponding to the contract parameters object
57
   pointed to by contract in the variable pointed
58
   to by network_id. If the contract is not a network
59
   one and therefore has not a network_id set, it
60
   puts the FSF_NULL_NETWORK_ID constant instead.
899 trimarchi 61
 
985 julio 62
   @param [in] contract     the pointer to the contract object
63
   @param [out] network_id  pointer to the variable that will contain
64
     the network identifier
65
 
66
   @retval 0 if the operation is succesful
67
   @retval FSF_ERR_BAD_ARGUMENT if any of the pointers is null.
929 lipari 68
*/
899 trimarchi 69
int
70
fsf_get_contract_network_id
71
  (const fsf_contract_parameters_t *contract,
72
   fsf_network_id_t                *network_id);
73
 
985 julio 74
 
899 trimarchi 75
//Transmission services:
76
 
929 lipari 77
/**
78
 
79
   \ingroup distjmodule
80
 
985 julio 81
   This operation creates a unidirectional input
82
   data endpoint through which, after the
83
   corresponding binding, it is possible to send
84
   data.  network_id identifies the network to use,
85
   receiver specifies the communication protocol
86
   dependent information that is necessary to
87
   address the receiving node, and port specifies
88
   the communication protocol dependent information
89
   that is necessary to get in contact with the
90
   desired destination.  
899 trimarchi 91
 
985 julio 92
   @param [in] network_id the identifier ot the network to use
93
   @param [in] receiver   protocol dependent information used
94
     to address the receiving node
95
   @param [in] port       protocol dependent information used
96
     to get in contact with the desired destination process
97
   @param [out] endpoint  pointer to the variable that will
98
     contain the send endpoint
99
 
100
   @retval 0 if the operation is succesful
101
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, netwok_id
102
     is not valid or if the receiver or the port do not conform
103
     to their expected formats
929 lipari 104
*/
899 trimarchi 105
int
106
fsf_create_send_endpoint
107
  (fsf_network_id_t      network_id,
108
   fsf_node_address_t    receiver,
109
   fsf_port_t            port,
110
   fsf_send_endpoint_t  *endpoint);
111
 
929 lipari 112
/**
113
   \ingroup distjmodule
114
 
985 julio 115
   This operation eliminates any resources reserved
116
   for the referenced endpoint. If the endpoint is
117
   bound to a network server, it is unbound from it
118
   and can not be further used to invoke send
119
   operations on it.  
120
 
121
   @param endpoint        pointer to the endpoint to eliminate
122
 
123
   @retval 0 if the operation is succesful
124
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
929 lipari 125
*/
899 trimarchi 126
int
127
fsf_destroy_send_endpoint
128
  (fsf_send_endpoint_t  *endpoint);
129
 
929 lipari 130
/**
131
   \ingroup distjmodule
132
 
985 julio 133
   This operation returns (except for those NULL
134
   arguments) in the variables pointed to by
135
   network_id, receiver, or port, the corresponding
136
   parameters used in the creation of the given
137
   send endpoint.
138
 
139
   @param [in] endpoint     pointer to the endpoint
140
   @param [out] network_id  pointer to variable the will contain
141
     the network id
142
   @param [out] receiver    pointer to variable the will contain
143
     the protocol dependent information used to address the
144
     receiving node
145
   @param [out] port        pointer to variable the will contain
146
     the protocol dependent information used to get in contact
147
     with the desired destination process
148
 
149
   @retval 0 if the operation is succesful
150
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
151
     or all the other pointers are NULL.
152
 
929 lipari 153
*/
899 trimarchi 154
int
155
fsf_get_send_endpoint_parameters
156
  (const fsf_send_endpoint_t  *endpoint,
157
   fsf_network_id_t           *network_id,
158
   fsf_node_address_t         *receiver,
159
   fsf_port_t                 *port);
160
 
929 lipari 161
/**
162
   \ingroup distjmodule
163
 
985 julio 164
   This operation associates a send endpoint with a
165
   server, which means that messages sent through
166
   that endpoint will consume the server's reserved
167
   bandwidth and its packets will be sent according
168
   to the contract established for that server.  If
169
   the endpoint is already bound to another server,
170
   it is effectively unbound from it and bound to
171
   the specified one.  
172
 
173
   @param [in] server       server id
174
   @param endpoint          pointer to the endpoint
175
 
176
   @retval 0 if the operation is succesful
177
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
178
     or server is not valid.
179
   @retval FSF_ERR_ALREADY_BOUND if the server is already
180
     bound to some other send endpoint
181
   @retval FSF_ERR_WRONG_NETWORK if the server network id
182
     is not the same as the one in the endpoint
183
*/
899 trimarchi 184
int
929 lipari 185
fsf_bind_endpoint_to_server
186
  (fsf_server_id_t server,
187
   fsf_send_endpoint_t *endpoint);
899 trimarchi 188
 
929 lipari 189
/**
190
   \ingroup distjmodule
191
 
985 julio 192
   This operation unbinds a send endpoint from a
193
   server. Endpoints with no server associated
194
   cannot be used to send data, and they stay in
195
   that state  until they are either eliminated or
196
   bound again.  
197
 
198
   @param endpoint        pointer to the endpoint to unbind
199
 
200
   @retval 0 if the operation is succesful
201
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
202
   @retval FSF_ERR_NOT_BOUND if the endpoint has no server
203
     bound
204
 */
899 trimarchi 205
int
206
fsf_unbind_endpoint_from_server
207
  (fsf_send_endpoint_t  *endpoint);
208
 
929 lipari 209
/**
210
   \ingroup distjmodule
211
 
985 julio 212
   This operation copies the id of the server that
213
   is bound to the specified send endpoint into the
214
   variable pointed to by server.
215
 
216
   @param [in] endpoint      pointer to the endpoint
217
   @param [out] server       pointer to variable the will contain
218
     the server id
219
 
220
   @retval 0 if the operation is succesful
221
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
222
     or server is NULL.
929 lipari 223
*/
899 trimarchi 224
int
225
fsf_get_endpoint_server
226
  (const fsf_send_endpoint_t  *endpoint,
227
   fsf_server_id_t            *server);
228
 
929 lipari 229
 
230
/**
231
   \ingroup distjmodule
232
 
985 julio 233
   This operation sends a message stored in msg and of length size
234
   through the given endpoint. The operation is non-blocking and
235
   returns immediately. An internal fsf service will schedule the
236
   sending of messages and implement the communications sporadic server
237
   corresponding to the network server bound to the given endpoint.
238
   Messages sent through the same endpoint are received in the same
239
   order in which they were sent
240
 
241
   @param endpoint      pointer to the endpoint
242
   @param [in] msg      pointer to the message
243
   @param [in] size     number of bytes to transmitt
244
 
245
   @retval 0 if the operation is succesful
246
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
247
     or msg is NULL
248
   @retval FSF_ERR_NOT_BOUND if endpoint is not bound to a valid
249
     server;
250
   @retval FSF_ERR_TOO_LARGE if the message is too large for the
251
     network protocol
252
   @retval FSF_ERR_BUFFER_FULL if the sending queue is full
253
*/
899 trimarchi 254
int
255
fsf_send
256
  (const fsf_send_endpoint_t  *endpoint,
257
   void                       *msg,
258
   size_t                      size);
259
 
929 lipari 260
/**
261
   \ingroup distjmodule
262
 
985 julio 263
   This operation creates a receive endpoint with all the information
264
   that is necessary to receive information from the specified network
265
   and port
266
 
267
   @param [in] network_id the identifier ot the network to use
268
   @param [in] port       protocol dependent information used
269
     to identify the calling process as an expecting destination
270
   @param [out] endpoint  pointer to the variable that will
271
     contain the receive endpoint
272
 
273
   @retval 0 if the operation is succesful
274
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, network_id
275
     is not valid or if port do not conform to the expected format
276
*/
899 trimarchi 277
int
278
fsf_create_receive_endpoint
279
  (fsf_network_id_t         network_id,
280
   fsf_port_t               port,
281
   fsf_receive_endpoint_t  *endpoint);
282
 
929 lipari 283
/**
284
   \ingroup distjmodule
285
 
985 julio 286
   If there are no messages available in the specified receive endpoint
287
   this operation blocks the calling thread waiting for a message to be
288
   received. When a message is available, if its size is less than or
289
   equal to the buffersize, the function stores it in the variable
290
   pointed to by buffer and puts the number of bytes received in the
291
   variable pointed to by messagesize. Messages arriving at a receiver
292
   buffer that is full will be silently discarded. The application is
293
   responsible of reading the receive endpoints with appropriate
294
   regularity, or of using a sequence number or some other mechanism
295
   to detect any lost messages.
296
 
297
   @param endpoint          pointer to the endpoint
298
   @param [out] buffer      pointer to the place that will contain
299
     the message received
300
   @param [in] buffersize   size of the buffer space
301
   @param [out] messagesize pointer to the variable that will contain
302
     the number of bytes received
303
 
304
   @retval 0 if the operation is succesful
305
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
306
     or if buffer or messagesize are NULL.
307
   @retval FSF_ERR_NO_SPACE if the buffersize is too small for the
308
     message received (in which case the message is lost).  
309
*/
899 trimarchi 310
int
311
fsf_receive
312
  (const fsf_receive_endpoint_t  *endpoint,
313
   void                          *buffer,
314
   size_t                         buffersize,
315
   size_t                        *messagesize);
316
 
929 lipari 317
/**
318
   \ingroup distjmodule
319
 
985 julio 320
   This operation is the same as fsf_receive, except
321
   that if there are no messages available in the
322
   specified receive endpoint at the time of the call
323
   the operation returns with an error
324
 
325
   @param endpoint          pointer to the endpoint
326
   @param [out] buffer      pointer to the place that will contain
327
     the message received
328
   @param [in] buffersize   size of the buffer space
329
   @param [out] messagesize pointer to the variable that will contain
330
     the number of bytes received
331
 
332
   @retval 0 if the operation is succesful
333
   @retval FSF_ERR_BAD_ARGUMENT if endpoint is null, or not valid
334
     or if buffer or messagesize are NULL.
335
   @retval FSF_ERR_NO_SPACE if the buffersize is too small for the
336
     message received (in which case the message is lost).  
337
   @retval FSF_ERR_NO_MESSAGES if there are no messages available
338
     in the specified receive endpoint at the time of the call
339
*/
899 trimarchi 340
int
341
fsf_try_receive
342
  (const fsf_receive_endpoint_t  *endpoint,
343
   void                          *buffer,
344
   size_t                         buffersize,
345
   size_t                        *messagesize);
346
 
929 lipari 347
/**
348
   \ingroup distjmodule
349
 
985 julio 350
   This operation is used to calculate a budget represented as
351
   a time magnitude, for a specified network. If succesful, the
352
   operation puts in the variable pointed to by budget the
353
   transmission time that it takes to send a packet through the
354
   network designated by network_id, when there is no contention,
355
   but including any network overheads.
356
 
357
   @param [in] network_id  the identifier ot the network to use
358
   @param [out] budget     pointer to the variable tha will contain
359
     the time it takes to transmitt a packet
899 trimarchi 360
 
985 julio 361
   @retval 0 if the operation is succesful
362
   @retval FSF_ERR_BAD_ARGUMENT if network_id is not a valid
363
     network identifier of if budget is a NULL pointer
364
*/
365
int
366
fsf_packet_tx_time
367
  (fsf_network_id_t      network_id,
368
   struct timespec       *budget);
369
 
929 lipari 370
/**
371
   \ingroup distjmodule
372
 
985 julio 373
   This operation puts in the variable pointed to by
374
   packet_size the maximum number of bytes that can be sent
375
   in a packet through the network designated by network_id.
376
   It is usually a configuration value and it helps the user
377
   application to calculate the number of packets it will
378
   need to reserve for the periodic transmision of its
379
   messages and prepare the corresponding contracts.
380
 
381
   @param [in] network_id   the identifier ot the network to use
382
   @param [out] packet_size pointer to the variable tha will contain
383
     the maximum size in bytes of a packet
384
 
385
   @retval 0 if the operation is succesful
386
   @retval FSF_ERR_BAD_ARGUMENT if network_id is not a valid
387
     network identifier of if packet_size is a NULL pointer
388
*/
389
int
390
fsf_packet_size
391
  (fsf_network_id_t      network_id,
392
   size_t               *packet_size);
393
 
394
 
395
/**
396
   \ingroup distjmodule
397
 
398
   This operation is used to obtain the maximum number of
399
   packets of which a message can be formed, for the
400
   specified network. A message is defined as the piece of
401
   information used in a send operation. Since the value
402
   returned by this operation is measured in packet units,
403
   the effective size can be calculated multiplying this
404
   value by the size of a packet.  When the value returned by
405
   this operation is larger than 1 it means the
406
   implementation will make the partition of messages into
407
   packets and its recomposition at the receiving node.
408
 
409
   @param [in] network_id    the identifier ot the network to use
410
   @param [out] max_msg_size pointer to the variable tha will contain
411
     the maximum number of packets sent in a single send operation
412
 
413
   @retval 0 if the operation is succesful
414
   @retval FSF_ERR_BAD_ARGUMENT if network_id is not a valid
415
     network identifier of if max_msg_size is a NULL pointer
416
*/
899 trimarchi 417
int
418
fsf_max_message_size
419
  (fsf_network_id_t      network_id,
420
   size_t                *max_msg_size);
421
 
422
 
985 julio 423
 
899 trimarchi 424
#endif // _FSF_DISTRIBUTED_H_