Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Implement file stat for storage model.
[simgrid.git] / src / simix / smx_smurf_private.h
1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SIMIX_SMURF_PRIVATE_H
8 #define _SIMIX_SMURF_PRIVATE_H
9
10 /********************************* Simcalls *********************************/
11
12 /* we want to build the e_smx_simcall_t enumeration and the table of the
13  * corresponding strings automatically, using macros */
14
15 #define SIMCALL_LIST1 \
16 SIMCALL_ENUM_ELEMENT(SIMCALL_NONE),\
17 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_BY_NAME),\
18 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_NAME),\
19 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_PROPERTIES),\
20 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_SPEED),\
21 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_AVAILABLE_SPEED),\
22 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_STATE),\
23 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_GET_DATA),\
24 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_SET_DATA),\
25 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTE),\
26 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_PARALLEL_EXECUTE),\
27 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_DESTROY),\
28 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_CANCEL),\
29 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_REMAINS),\
30 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_GET_STATE),\
31 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_SET_PRIORITY),\
32 SIMCALL_ENUM_ELEMENT(SIMCALL_HOST_EXECUTION_WAIT),\
33 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CREATE),\
34 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILL),\
35 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_KILLALL),\
36 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CLEANUP),\
37 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_CHANGE_HOST),\
38 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SUSPEND),\
39 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESUME),\
40 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_COUNT),\
41 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_DATA),\
42 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SET_DATA),\
43 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_HOST),\
44 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_NAME),\
45 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_IS_SUSPENDED),\
46 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_GET_PROPERTIES),\
47 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_SLEEP),\
48 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_CREATE),\
49 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\
50 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\
51 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\
52 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\
53 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\
54 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\
55 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\
56 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IRECV),\
57 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_DESTROY),\
58 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_CANCEL),\
59 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\
60 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\
61 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\
62 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\
63 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\
64 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\
65 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\
66 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_DATA),\
67 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_PROC),\
68 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_PROC),\
69 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_INIT),\
70 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_DESTROY),\
71 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_LOCK),\
72 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_TRYLOCK),\
73 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_UNLOCK),\
74 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_INIT),\
75 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_DESTROY),\
76 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_SIGNAL),\
77 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT),\
78 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT_TIMEOUT),\
79 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_BROADCAST),\
80 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_INIT),\
81 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_DESTROY),\
82 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_RELEASE),\
83 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_WOULD_BLOCK),\
84 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
85 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
86 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
87 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
88 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
89 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
90 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
91 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT)
92
93
94 /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
95  * because they are not always present */
96 #ifdef HAVE_LATENCY_BOUND_TRACKING
97 #define SIMCALL_LIST2 \
98 ,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED)
99 #else
100 #define SIMCALL_LIST2
101 #endif
102
103 #ifdef HAVE_TRACING
104 #define SIMCALL_LIST3 \
105 ,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY)
106 #else
107 #define SIMCALL_LIST3
108 #endif
109
110 /* SIMCALL_LIST is the final macro to use */
111 #define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3
112
113 /* you can redefine the following macro differently to generate something else
114  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
115 #define SIMCALL_ENUM_ELEMENT(x) x
116
117 /**
118  * \brief All possible simcalls.
119  */
120 typedef enum {
121 SIMCALL_LIST
122 } e_smx_simcall_t;
123
124 /**
125  * \brief Represents a simcall to the kernel.
126  */
127 typedef struct s_smx_simcall {
128   e_smx_simcall_t call;
129   smx_process_t issuer;
130
131   union {
132
133     struct {
134       const char *name;
135       smx_host_t result;
136     } host_get_by_name;
137
138     struct {
139       smx_host_t host;
140       const char* result;
141     } host_get_name;
142
143     struct {
144       smx_host_t host;
145       xbt_dict_t result;
146     } host_get_properties;
147
148     struct {
149       smx_host_t host;
150       double result;
151     } host_get_speed;
152
153     struct {
154       smx_host_t host;
155       double result;
156     } host_get_available_speed;
157
158     struct {
159       smx_host_t host;
160       int result;
161     } host_get_state;
162
163     struct {
164       smx_host_t host;
165       void* result;
166     } host_get_data;
167
168     struct {
169       smx_host_t host;
170       void* data;
171     } host_set_data;
172
173     struct {
174       const char* name;
175       smx_host_t host;
176       double computation_amount;
177       double priority;
178       smx_action_t result;
179     } host_execute;
180
181     struct {
182       const char *name;
183       int host_nb;
184       smx_host_t *host_list;
185       double *computation_amount;
186       double *communication_amount;
187       double amount;
188       double rate;
189       smx_action_t result;
190     } host_parallel_execute;
191
192     struct {
193       smx_action_t execution;
194     } host_execution_destroy;
195
196     struct {
197       smx_action_t execution;
198     } host_execution_cancel;
199
200     struct {
201       smx_action_t execution;
202       double result;
203     } host_execution_get_remains;
204
205     struct {
206       smx_action_t execution;
207       e_smx_state_t result;
208     } host_execution_get_state;
209
210     struct {
211       smx_action_t execution;
212       double priority;
213     } host_execution_set_priority;
214
215     struct {
216       smx_action_t execution;
217       e_smx_state_t result;
218     } host_execution_wait;
219
220     struct {
221       smx_process_t *process;
222       const char *name;
223       xbt_main_func_t code;
224       void *data;
225       const char *hostname;
226       int argc;
227       char **argv;
228       xbt_dict_t properties;
229     } process_create;
230
231     struct {
232       smx_process_t process;
233     } process_kill;
234
235     struct {
236       smx_process_t process;
237     } process_cleanup;
238
239     struct {
240       smx_process_t process;
241       smx_host_t dest;
242     } process_change_host;
243
244     struct {
245       smx_process_t process;
246     } process_suspend;
247
248     struct {
249       smx_process_t process;
250     } process_resume;
251
252     struct {
253       int result;
254     } process_count;
255
256     struct {
257       smx_process_t process;
258       void* result;
259     } process_get_data;
260
261     struct {
262       smx_process_t process;
263       void* data;
264     } process_set_data;
265
266     struct {
267       smx_process_t process;
268       smx_host_t result;
269     } process_get_host;
270
271     struct {
272       smx_process_t process;
273       const char *result;
274     } process_get_name;
275
276     struct {
277       smx_process_t process;
278       int result;
279     } process_is_suspended;
280
281     struct {
282       smx_process_t process;
283       xbt_dict_t result;
284     } process_get_properties;
285
286     struct {
287       double duration;
288       e_smx_state_t result;
289     } process_sleep;
290
291     struct {
292       const char *name;
293       smx_rdv_t result;
294     } rdv_create;
295
296     struct {
297       smx_rdv_t rdv;
298     } rdv_destroy;
299
300     struct {
301       const char* name;
302       smx_rdv_t result;
303     } rdv_get_by_name;
304
305     struct {
306       smx_rdv_t rdv;
307       smx_host_t host;
308       unsigned int result; 
309     } rdv_comm_count_by_host;
310
311     struct {
312       smx_rdv_t rdv;
313       smx_action_t result;
314     } rdv_get_head;
315
316     struct {
317       smx_rdv_t rdv;
318       double task_size;
319       double rate;
320       void *src_buff;
321       size_t src_buff_size;
322       int (*match_fun)(void *, void *);
323       void *data;
324       double timeout;
325     } comm_send;
326
327     struct {
328       smx_rdv_t rdv;
329       double task_size;
330       double rate;
331       void *src_buff;
332       size_t src_buff_size;
333       int (*match_fun)(void *, void *);
334       void (*clean_fun)(void *);
335       void *data;
336       int detached;
337       smx_action_t result;
338     } comm_isend;
339
340     struct {
341       smx_rdv_t rdv;
342       void *dst_buff;
343       size_t *dst_buff_size;
344       int (*match_fun)(void *, void *);
345       void *data;
346       double timeout;
347     } comm_recv;
348
349     struct {
350       smx_rdv_t rdv;
351       void *dst_buff;
352       size_t *dst_buff_size;
353       int (*match_fun)(void *, void *);
354           void *data;
355       smx_action_t result;
356     } comm_irecv;
357
358     struct {
359       smx_action_t comm;
360     } comm_destroy;
361
362     struct {
363       smx_action_t comm;
364     } comm_cancel;
365
366     struct {
367       xbt_dynar_t comms;
368       unsigned int result;
369     } comm_waitany;
370
371     struct {
372       smx_action_t comm;
373       double timeout;
374     } comm_wait;
375
376     struct {
377       smx_action_t comm;
378       int result;
379     } comm_test;
380
381     struct {
382       xbt_dynar_t comms;
383       int result;
384     } comm_testany;
385
386     struct {
387       smx_action_t comm;
388       double result;
389     } comm_get_remains;
390
391     struct {
392       smx_action_t comm;
393       e_smx_state_t result;
394     } comm_get_state;
395
396     struct {
397       smx_action_t comm;
398       void *result;
399     } comm_get_src_data;
400
401     struct {
402       smx_action_t comm;
403       void *result;
404     } comm_get_dst_data;
405
406     struct {
407       smx_action_t comm;
408       smx_process_t result;
409     } comm_get_src_proc;
410
411     struct {
412       smx_action_t comm;
413       smx_process_t result;
414     } comm_get_dst_proc;
415
416 #ifdef HAVE_LATENCY_BOUND_TRACKING
417     struct {
418       smx_action_t comm;
419       int result;
420     } comm_is_latency_bounded;
421 #endif
422
423 #ifdef HAVE_TRACING
424     struct {
425       smx_action_t action;
426       const char *category;
427     } set_category;
428 #endif
429
430     struct {
431       smx_mutex_t result;
432     } mutex_init;
433
434     struct {
435       smx_mutex_t mutex;
436     } mutex_lock;
437
438     struct {
439       smx_mutex_t mutex;
440       int result;
441     } mutex_trylock;
442
443     struct {
444       smx_mutex_t mutex;
445     } mutex_unlock;
446
447     struct {
448       smx_mutex_t mutex;
449     } mutex_destroy;
450
451     struct {
452       smx_cond_t result;
453     } cond_init;
454
455     struct {
456       smx_cond_t cond;
457     } cond_destroy;
458
459     struct {
460       smx_cond_t cond;
461     } cond_signal;
462
463     struct {
464       smx_cond_t cond;
465       smx_mutex_t mutex;
466     } cond_wait;
467
468     struct {
469       smx_cond_t cond;
470       smx_mutex_t mutex;
471       double timeout;
472     } cond_wait_timeout;
473
474     struct {
475       smx_cond_t cond;
476     } cond_broadcast;
477
478     struct {
479       int capacity;
480       smx_sem_t result;
481     } sem_init;
482
483     struct {
484       smx_sem_t sem;
485     } sem_destroy;
486
487     struct {
488       smx_sem_t sem;
489     } sem_release;
490
491     struct {
492       smx_sem_t sem;
493       int result;
494     } sem_would_block;
495
496     struct {
497       smx_sem_t sem;
498     } sem_acquire;
499
500     struct {
501       smx_sem_t sem;
502       double timeout;
503     } sem_acquire_timeout;
504
505     struct {
506       smx_sem_t sem;
507       int result;
508     } sem_get_capacity;
509
510     struct {
511       const char* storage;
512       void *ptr;
513       size_t size;
514       size_t nmemb;
515       smx_file_t stream;
516       size_t result;
517     } file_read;
518
519     struct {
520       const char* storage;
521       const void *ptr;
522       size_t size;
523       size_t nmemb;
524       smx_file_t stream;
525       size_t result;
526     } file_write;
527
528     struct {
529       const char* storage;
530       const char* path;
531       const char* mode;
532       smx_file_t result;
533     } file_open;
534
535     struct {
536       const char* storage;
537       smx_file_t fp;
538       int result;
539     } file_close;
540
541     struct {
542       const char* storage;
543       smx_file_t fd;
544       s_file_stat_t buf;
545       int result;
546     } file_stat;
547
548   };
549 } s_smx_simcall_t, *smx_simcall_t;
550
551 /******************************** General *************************************/
552
553 void SIMIX_simcall_push(smx_process_t self);
554 void SIMIX_simcall_answer(smx_simcall_t);
555 void SIMIX_simcall_pre(smx_simcall_t, int);
556 void SIMIX_simcall_post(smx_action_t);
557 smx_simcall_t SIMIX_simcall_mine(void);
558 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
559
560 #endif
561