Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : New public functions to take a snapshot and compare two snapshots...
[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_PROCESS_ON_EXIT),\
49 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_AUTO_RESTART_SET),\
50 SIMCALL_ENUM_ELEMENT(SIMCALL_PROCESS_RESTART),\
51 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_CREATE),\
52 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_DESTROY),\
53 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GEY_BY_NAME),\
54 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_COMM_COUNT_BY_HOST),\
55 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_HEAD),\
56 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_SET_RECV),\
57 SIMCALL_ENUM_ELEMENT(SIMCALL_RDV_GET_RECV),\
58 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_SEND),\
59 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_ISEND),\
60 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_RECV),\
61 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IRECV),\
62 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_DESTROY),\
63 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_CANCEL),\
64 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAITANY),\
65 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_WAIT),\
66 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TEST),\
67 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_TESTANY),\
68 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IPROBE),\
69 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_REMAINS),\
70 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_STATE),\
71 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_DATA),\
72 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_DATA),\
73 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_SRC_PROC),\
74 SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_GET_DST_PROC),\
75 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_INIT),\
76 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_DESTROY),\
77 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_LOCK),\
78 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_TRYLOCK),\
79 SIMCALL_ENUM_ELEMENT(SIMCALL_MUTEX_UNLOCK),\
80 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_INIT),\
81 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_DESTROY),\
82 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_SIGNAL),\
83 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT),\
84 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_WAIT_TIMEOUT),\
85 SIMCALL_ENUM_ELEMENT(SIMCALL_COND_BROADCAST),\
86 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_INIT),\
87 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_DESTROY),\
88 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_RELEASE),\
89 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_WOULD_BLOCK),\
90 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE),\
91 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_ACQUIRE_TIMEOUT),\
92 SIMCALL_ENUM_ELEMENT(SIMCALL_SEM_GET_CAPACITY),\
93 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_READ),\
94 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_WRITE),\
95 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_OPEN),\
96 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_CLOSE),\
97 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_STAT), \
98 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_UNLINK),\
99 SIMCALL_ENUM_ELEMENT(SIMCALL_FILE_LS),\
100 SIMCALL_ENUM_ELEMENT(SIMCALL_ASR_GET_PROPERTIES), \
101 SIMCALL_ENUM_ELEMENT(SIMCALL_MC_SNAPSHOT), \
102 SIMCALL_ENUM_ELEMENT(SIMCALL_MC_COMPARE_SNAPSHOTS), \
103 /* ****************************************************************************************** */ \
104 /* TUTORIAL: New API                                                                        */ \
105 /* ****************************************************************************************** */ \
106 SIMCALL_ENUM_ELEMENT(SIMCALL_NEW_API_INIT)
107
108
109 /* SIMCALL_COMM_IS_LATENCY_BOUNDED and SIMCALL_SET_CATEGORY make things complicated
110  * because they are not always present */
111 #ifdef HAVE_LATENCY_BOUND_TRACKING
112 #define SIMCALL_LIST2 \
113 ,SIMCALL_ENUM_ELEMENT(SIMCALL_COMM_IS_LATENCY_BOUNDED)
114 #else
115 #define SIMCALL_LIST2
116 #endif
117
118 #ifdef HAVE_TRACING
119 #define SIMCALL_LIST3 \
120 ,SIMCALL_ENUM_ELEMENT(SIMCALL_SET_CATEGORY)
121 #else
122 #define SIMCALL_LIST3
123 #endif
124
125 /* SIMCALL_LIST is the final macro to use */
126 #define SIMCALL_LIST SIMCALL_LIST1 SIMCALL_LIST2 SIMCALL_LIST3
127
128 /* you can redefine the following macro differently to generate something else
129  * with the list of enumeration values (e.g. a table of strings or a table of function pointers) */
130 #define SIMCALL_ENUM_ELEMENT(x) x
131
132 /**
133  * \brief All possible simcalls.
134  */
135 typedef enum {
136 SIMCALL_LIST
137 } e_smx_simcall_t;
138
139 /**
140  * \brief Represents a simcall to the kernel.
141  */
142 typedef struct s_smx_simcall {
143   e_smx_simcall_t call;
144   smx_process_t issuer;
145
146   union {
147
148     struct {
149       const char *name;
150       smx_host_t result;
151     } host_get_by_name;
152
153     struct {
154       smx_host_t host;
155       const char* result;
156     } host_get_name;
157
158     struct {
159       smx_host_t host;
160       xbt_dict_t result;
161     } host_get_properties;
162
163     struct {
164       smx_host_t host;
165       double result;
166     } host_get_speed;
167
168     struct {
169       smx_host_t host;
170       double result;
171     } host_get_available_speed;
172
173     struct {
174       smx_host_t host;
175       int result;
176     } host_get_state;
177
178     struct {
179       smx_host_t host;
180       void* result;
181     } host_get_data;
182
183     struct {
184       smx_host_t host;
185       void* data;
186     } host_set_data;
187
188     struct {
189       const char* name;
190       smx_host_t host;
191       double computation_amount;
192       double priority;
193       smx_action_t result;
194     } host_execute;
195
196     struct {
197       const char *name;
198       int host_nb;
199       smx_host_t *host_list;
200       double *computation_amount;
201       double *communication_amount;
202       double amount;
203       double rate;
204       smx_action_t result;
205     } host_parallel_execute;
206
207     struct {
208       smx_action_t execution;
209     } host_execution_destroy;
210
211     struct {
212       smx_action_t execution;
213     } host_execution_cancel;
214
215     struct {
216       smx_action_t execution;
217       double result;
218     } host_execution_get_remains;
219
220     struct {
221       smx_action_t execution;
222       e_smx_state_t result;
223     } host_execution_get_state;
224
225     struct {
226       smx_action_t execution;
227       double priority;
228     } host_execution_set_priority;
229
230     struct {
231       smx_action_t execution;
232       e_smx_state_t result;
233     } host_execution_wait;
234
235     struct {
236       smx_process_t *process;
237       const char *name;
238       xbt_main_func_t code;
239       void *data;
240       const char *hostname;
241       double kill_time;
242       int argc;
243       char **argv;
244       xbt_dict_t properties;
245       int auto_restart;
246     } process_create;
247
248     struct {
249       smx_process_t process;
250     } process_kill;
251
252     struct {
253       smx_process_t process;
254     } process_cleanup;
255
256     struct {
257       smx_process_t process;
258       smx_host_t dest;
259     } process_change_host;
260
261     struct {
262       smx_process_t process;
263     } process_suspend;
264
265     struct {
266       smx_process_t process;
267     } process_resume;
268
269     struct {
270       int result;
271     } process_count;
272
273     struct {
274       smx_process_t process;
275       void* result;
276     } process_get_data;
277
278     struct {
279       smx_process_t process;
280       void* data;
281     } process_set_data;
282
283     struct {
284       smx_process_t process;
285       smx_host_t result;
286     } process_get_host;
287
288     struct {
289       smx_process_t process;
290       const char *result;
291     } process_get_name;
292
293     struct {
294       smx_process_t process;
295       int result;
296     } process_is_suspended;
297
298     struct {
299       smx_process_t process;
300       xbt_dict_t result;
301     } process_get_properties;
302
303     struct {
304       double duration;
305       e_smx_state_t result;
306     } process_sleep;
307
308     struct {
309       smx_process_t process;
310       int_f_pvoid_t fun;
311       void *data;
312     } process_on_exit;
313
314     struct {
315       smx_process_t process;
316       int auto_restart;
317     } process_auto_restart;
318
319     struct {
320       smx_process_t process;
321       smx_process_t result;
322     } process_restart;
323
324     struct {
325       const char *name;
326       smx_rdv_t result;
327     } rdv_create;
328
329     struct {
330       smx_rdv_t rdv;
331     } rdv_destroy;
332
333     struct {
334       const char* name;
335       smx_rdv_t result;
336     } rdv_get_by_name;
337
338     struct {
339       smx_rdv_t rdv;
340       smx_host_t host;
341       unsigned int result; 
342     } rdv_comm_count_by_host;
343
344     struct {
345       smx_rdv_t rdv;
346       smx_action_t result;
347     } rdv_get_head;
348
349     struct {
350       smx_rdv_t rdv;
351       smx_process_t receiver;
352     } rdv_set_rcv_proc;
353
354     struct {
355       smx_rdv_t rdv;
356       smx_process_t result;
357     } rdv_get_rcv_proc;
358
359     struct {
360       smx_rdv_t rdv;
361       double task_size;
362       double rate;
363       void *src_buff;
364       size_t src_buff_size;
365       int (*match_fun)(void *, void *, smx_action_t);
366       void *data;
367       double timeout;
368     } comm_send;
369
370     struct {
371       smx_rdv_t rdv;
372       double task_size;
373       double rate;
374       void *src_buff;
375       size_t src_buff_size;
376       int (*match_fun)(void *, void *, smx_action_t);
377       void (*clean_fun)(void *);
378       void *data;
379       int detached;
380       smx_action_t result;
381     } comm_isend;
382
383     struct {
384       smx_rdv_t rdv;
385       void *dst_buff;
386       size_t *dst_buff_size;
387       int (*match_fun)(void *, void *, smx_action_t);
388       void *data;
389       double timeout;
390     } comm_recv;
391
392     struct {
393       smx_rdv_t rdv;
394       void *dst_buff;
395       size_t *dst_buff_size;
396       int (*match_fun)(void *, void *, smx_action_t);
397       void *data;
398       smx_action_t result;
399     } comm_irecv;
400
401     struct {
402       smx_rdv_t rdv;
403       int src;
404       int tag;
405       int (*match_fun)(void *, void *, smx_action_t);
406       void *data;
407       smx_action_t result;
408     } comm_iprobe;
409
410     struct {
411       smx_action_t comm;
412     } comm_destroy;
413
414     struct {
415       smx_action_t comm;
416     } comm_cancel;
417
418     struct {
419       xbt_dynar_t comms;
420       unsigned int result;
421     } comm_waitany;
422
423     struct {
424       smx_action_t comm;
425       double timeout;
426     } comm_wait;
427
428     struct {
429       smx_action_t comm;
430       int result;
431     } comm_test;
432
433     struct {
434       xbt_dynar_t comms;
435       int result;
436     } comm_testany;
437
438     struct {
439       smx_action_t comm;
440       double result;
441     } comm_get_remains;
442
443     struct {
444       smx_action_t comm;
445       e_smx_state_t result;
446     } comm_get_state;
447
448     struct {
449       smx_action_t comm;
450       void *result;
451     } comm_get_src_data;
452
453     struct {
454       smx_action_t comm;
455       void *result;
456     } comm_get_dst_data;
457
458     struct {
459       smx_action_t comm;
460       smx_process_t result;
461     } comm_get_src_proc;
462
463     struct {
464       smx_action_t comm;
465       smx_process_t result;
466     } comm_get_dst_proc;
467
468 #ifdef HAVE_LATENCY_BOUND_TRACKING
469     struct {
470       smx_action_t comm;
471       int result;
472     } comm_is_latency_bounded;
473 #endif
474
475 #ifdef HAVE_TRACING
476     struct {
477       smx_action_t action;
478       const char *category;
479     } set_category;
480 #endif
481
482     struct {
483       smx_mutex_t result;
484     } mutex_init;
485
486     struct {
487       smx_mutex_t mutex;
488     } mutex_lock;
489
490     struct {
491       smx_mutex_t mutex;
492       int result;
493     } mutex_trylock;
494
495     struct {
496       smx_mutex_t mutex;
497     } mutex_unlock;
498
499     struct {
500       smx_mutex_t mutex;
501     } mutex_destroy;
502
503     struct {
504       smx_cond_t result;
505     } cond_init;
506
507     struct {
508       smx_cond_t cond;
509     } cond_destroy;
510
511     struct {
512       smx_cond_t cond;
513     } cond_signal;
514
515     struct {
516       smx_cond_t cond;
517       smx_mutex_t mutex;
518     } cond_wait;
519
520     struct {
521       smx_cond_t cond;
522       smx_mutex_t mutex;
523       double timeout;
524     } cond_wait_timeout;
525
526     struct {
527       smx_cond_t cond;
528     } cond_broadcast;
529
530     struct {
531       int capacity;
532       smx_sem_t result;
533     } sem_init;
534
535     struct {
536       smx_sem_t sem;
537     } sem_destroy;
538
539     struct {
540       smx_sem_t sem;
541     } sem_release;
542
543     struct {
544       smx_sem_t sem;
545       int result;
546     } sem_would_block;
547
548     struct {
549       smx_sem_t sem;
550     } sem_acquire;
551
552     struct {
553       smx_sem_t sem;
554       double timeout;
555     } sem_acquire_timeout;
556
557     struct {
558       smx_sem_t sem;
559       int result;
560     } sem_get_capacity;
561
562     struct {
563       void *ptr;
564       size_t size;
565       size_t nmemb;
566       smx_file_t stream;
567       double result;
568     } file_read;
569
570     struct {
571       const void *ptr;
572       size_t size;
573       size_t nmemb;
574       smx_file_t stream;
575       size_t result;
576     } file_write;
577
578     struct {
579       const char* mount;
580       const char* path;
581       const char* mode;
582       smx_file_t result;
583     } file_open;
584
585     struct {
586       smx_file_t fp;
587       int result;
588     } file_close;
589
590     struct {
591       smx_file_t fd;
592       s_file_stat_t buf;
593       int result;
594     } file_stat;
595
596     struct {
597       smx_file_t fd;
598       int result;
599     } file_unlink;
600
601     struct {
602       const char *mount;
603       const char *path;
604       xbt_dict_t result;
605     } file_ls;
606
607     struct {
608       const char* name;
609       xbt_dict_t result;
610     } asr_get_properties;
611
612     struct{
613       void *s;
614     } mc_snapshot;
615
616     struct{
617       void *snapshot1;
618       void *snapshot2;
619       int result;
620     } mc_compare_snapshots;
621
622     /* ****************************************************************************************** */
623     /* TUTORIAL: New API                                                                        */
624     /* ****************************************************************************************** */
625     struct {
626       const char* param1;
627       double param2;
628       int result;
629     } new_api;
630
631   };
632 } s_smx_simcall_t, *smx_simcall_t;
633
634 /******************************** General *************************************/
635
636 void SIMIX_simcall_push(smx_process_t self);
637 void SIMIX_simcall_answer(smx_simcall_t);
638 void SIMIX_simcall_pre(smx_simcall_t, int);
639 void SIMIX_simcall_post(smx_action_t);
640 smx_simcall_t SIMIX_simcall_mine(void);
641 const char *SIMIX_simcall_name(e_smx_simcall_t kind);
642
643 #endif
644