Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make SIMIX_req_host_execution_wait to also destroy the execution action when done.
[simgrid.git] / src / simix / smx_user.c
1 #include "private.h"
2
3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
4
5 static const char* request_names[] = {
6 #undef SIMIX_REQ_ENUM_ELEMENT
7 #define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
8 SIMIX_REQ_LIST
9 #undef SIMIX_REQ_ENUM_ELEMENT
10 };
11
12 /**
13  * \brief Returns a host given its name.
14  *
15  * \param name The name of the host to get
16  * \return The corresponding host
17  */
18 smx_host_t SIMIX_req_host_get_by_name(const char *name)
19 {
20   smx_req_t req = SIMIX_req_mine();
21
22   req->call = REQ_HOST_GET_BY_NAME;
23   req->host_get_by_name.name = name;
24   SIMIX_request_push();
25   return req->host_get_by_name.result;
26 }
27
28 /**
29  * \brief Returns the name of a host.
30  *
31  * \param host A SIMIX host
32  * \return The name of this host
33  */
34 const char* SIMIX_req_host_get_name(smx_host_t host)
35 {
36   smx_req_t req = SIMIX_req_mine();
37
38   req->call = REQ_HOST_GET_NAME;
39   req->host_get_name.host = host;
40   SIMIX_request_push();
41   return req->host_get_name.result;
42 }
43
44 /**
45  * \brief Returns a dict of the properties assigned to a host.
46  *
47  * \param host A host
48  * \return The properties of this host
49  */
50 xbt_dict_t SIMIX_req_host_get_properties(smx_host_t host)
51 {
52   smx_req_t req = SIMIX_req_mine();
53
54   req->call = REQ_HOST_GET_PROPERTIES;
55   req->host_get_properties.host = host;
56   SIMIX_request_push();
57   return req->host_get_properties.result;
58 }
59
60 /**
61  * \brief Returns the speed of the processor.
62  *
63  * The speed returned does not take into account the current load on the machine.
64  * \param host A SIMIX host
65  * \return The speed of this host (in Mflop/s)
66  */
67 double SIMIX_req_host_get_speed(smx_host_t host)
68 {
69   smx_req_t req = SIMIX_req_mine();
70
71   req->call = REQ_HOST_GET_SPEED;
72   req->host_get_speed.host = host;
73   SIMIX_request_push();
74   return req->host_get_speed.result;
75 }
76
77 /**
78  * \brief Returns the available speed of the processor.
79  *
80  * \return Speed currently available (in Mflop/s)
81  */
82 double SIMIX_req_host_get_available_speed(smx_host_t host)
83 {
84   smx_req_t req = SIMIX_req_mine();
85
86   req->call = REQ_HOST_GET_AVAILABLE_SPEED;
87   req->host_get_available_speed.host = host;
88   SIMIX_request_push();
89   return req->host_get_available_speed.result;
90 }
91
92 /**
93  * \brief Returns the state of a host.
94  *
95  * Two states are possible: 1 if the host is active or 0 if it has crashed.
96  * \param host A SIMIX host
97  * \return 1 if the host is available, 0 otherwise
98  */
99 int SIMIX_req_host_get_state(smx_host_t host)
100 {
101   smx_req_t req = SIMIX_req_mine();
102
103   req->call = REQ_HOST_GET_STATE;
104   req->host_get_state.host = host;
105   SIMIX_request_push();
106   return req->host_get_state.result;
107 }
108
109 /**
110  * \brief Returns the user data associated to a host.
111  *
112  * \param host SIMIX host
113  * \return the user data of this host
114  */
115 void* SIMIX_req_host_get_data(smx_host_t host)
116 {
117   smx_req_t req = SIMIX_req_mine();
118
119   req->call = REQ_HOST_GET_DATA;
120   req->host_get_data.host = host;
121   SIMIX_request_push();
122   return req->host_get_data.result;
123 }
124
125 /**
126  * \brief Sets the user data associated to a host.
127  *
128  * The host must not have previous user data associated to it.
129  * \param A host SIMIX host
130  * \param data The user data to set
131  */
132 void SIMIX_req_host_set_data(smx_host_t host, void *data)
133 {
134   smx_req_t req = SIMIX_req_mine();
135
136   req->call = REQ_HOST_SET_DATA;
137   req->host_set_data.host = host;
138   req->host_set_data.data = data;
139   SIMIX_request_push();
140 }
141
142 /** \brief Creates an action that executes some computation of an host.
143  *
144  * This function creates a SURF action and allocates the data necessary
145  * to create the SIMIX action. It can raise a host_error exception if the host crashed.
146  *
147  * \param name Name of the execution action to create
148  * \param host SIMIX host where the action will be executed
149  * \param amount Computation amount (in bytes)
150  * \return A new SIMIX execution action
151  */
152 smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
153                                     double computation_amount,
154                                     double priority)
155 {
156   smx_req_t req = SIMIX_req_mine();
157
158   req->call = REQ_HOST_EXECUTE;
159   req->host_execute.name = name;
160   req->host_execute.host = host;
161   req->host_execute.computation_amount = computation_amount;
162   req->host_execute.priority = priority;
163   SIMIX_request_push();
164   return req->host_execute.result;
165 }
166
167 /** \brief Creates an action that may involve parallel computation on
168  * several hosts and communication between them.
169  *
170  * \param name Name of the execution action to create
171  * \param host_nb Number of hosts where the action will be executed
172  * \param host_list Array (of size host_nb) of hosts where the action will be executed
173  * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
174  * \param communication_amount Array (of size host_nb * host_nb) representing the communication
175  * amount between each pair of hosts
176  * \param amount the SURF action amount
177  * \param rate the SURF action rate
178  * \return A new SIMIX execution action
179  */
180 smx_action_t SIMIX_req_host_parallel_execute(const char *name,
181                                          int host_nb,
182                                          smx_host_t *host_list,
183                                          double *computation_amount,
184                                          double *communication_amount,
185                                          double amount,
186                                          double rate)
187 {
188   smx_req_t req = SIMIX_req_mine();
189
190   req->call = REQ_HOST_PARALLEL_EXECUTE;
191   req->host_parallel_execute.name = name;
192   req->host_parallel_execute.host_nb = host_nb;
193   req->host_parallel_execute.host_list = host_list;
194   req->host_parallel_execute.computation_amount = computation_amount;
195   req->host_parallel_execute.communication_amount = communication_amount;
196   req->host_parallel_execute.amount = amount;
197   req->host_parallel_execute.rate = rate;
198   SIMIX_request_push();
199   return req->host_parallel_execute.result;
200 }
201
202 /**
203  * \brief Destroys an execution action.
204  *
205  * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
206  * \param action The execution action to destroy
207  */
208 void SIMIX_req_host_execution_destroy(smx_action_t execution)
209 {
210   smx_req_t req = SIMIX_req_mine();
211
212   req->call = REQ_HOST_EXECUTION_DESTROY;
213   req->host_execution_destroy.execution = execution;
214   SIMIX_request_push();
215 }
216
217 /**
218  * \brief Cancels an execution action.
219  *
220  * This functions stops the execution. It calls a surf function.
221  * \param action The execution action to cancel
222  */
223 void SIMIX_req_host_execution_cancel(smx_action_t execution)
224 {
225   smx_req_t req = SIMIX_req_mine();
226
227   req->call = REQ_HOST_EXECUTION_CANCEL;
228   req->host_execution_cancel.execution = execution;
229   SIMIX_request_push();
230 }
231
232 /**
233  * \brief Returns how much of an execution action remains to be done.
234  *
235  * \param Action The execution action
236  * \return The remaining amount
237  */
238 double SIMIX_req_host_execution_get_remains(smx_action_t execution)
239 {
240   smx_req_t req = SIMIX_req_mine();
241
242   req->call = REQ_HOST_EXECUTION_GET_REMAINS;
243   req->host_execution_get_remains.execution = execution;
244   SIMIX_request_push();
245   return req->host_execution_get_remains.result;
246 }
247
248 /**
249  * \brief Returns the state of an execution action.
250  *
251  * \param execution The execution action
252  * \return The state
253  */
254 e_smx_state_t SIMIX_req_host_execution_get_state(smx_action_t execution)
255 {
256   smx_req_t req = SIMIX_req_mine();
257
258   req->call = REQ_HOST_EXECUTION_GET_STATE;
259   req->host_execution_get_state.execution = execution;
260   SIMIX_request_push();
261   return req->host_execution_get_state.result;
262 }
263
264 /**
265  * \brief Changes the priority of an execution action.
266  *
267  * This functions changes the priority only. It calls a surf function.
268  * \param execution The execution action
269  * \param priority The new priority
270  */
271 void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priority)
272 {
273   smx_req_t req = SIMIX_req_mine();
274
275   req->call = REQ_HOST_EXECUTION_SET_PRIORITY;
276   req->host_execution_set_priority.execution = execution;
277   req->host_execution_set_priority.priority = priority;
278   SIMIX_request_push();
279 }
280
281 /**
282  * \brief Waits for the completion of an execution action and destroy it.
283  *
284  * \param execution The execution action
285  */
286 e_smx_state_t SIMIX_req_host_execution_wait(smx_action_t execution)
287 {
288   smx_req_t req = SIMIX_req_mine();
289
290   req->call = REQ_HOST_EXECUTION_WAIT;
291   req->host_execution_wait.execution = execution;
292   SIMIX_request_push();
293   return req->host_execution_wait.result;
294 }
295
296 /**
297  * \brief Creates and runs a new SIMIX process.
298  *
299  * The structure and the corresponding threada are created and put in the list of ready processes.
300  *
301  * \param name a name for the process. It is for user-level information and can be NULL.
302  * \param code the main function of the process
303  * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
304  * It can be retrieved with the function \ref SIMIX_req_process_get_data.
305  * \param hostname name of the host where the new agent is executed.
306  * \param argc first argument passed to \a code
307  * \param argv second argument passed to \a code
308  * \param properties the properties of the process
309  * \return The new process
310  */
311 smx_process_t SIMIX_req_process_create(const char *name,
312                                    xbt_main_func_t code,
313                                    void *data,
314                                    const char *hostname,
315                                    int argc, char **argv,
316                                    xbt_dict_t properties)
317 {
318   smx_req_t req = SIMIX_req_mine();
319
320   req->call = REQ_PROCESS_CREATE;
321   req->process_create.name = name;
322   req->process_create.code = code;
323   req->process_create.data = data;
324   req->process_create.hostname = hostname;
325   req->process_create.argc = argc;
326   req->process_create.argv = argv;
327   req->process_create.properties = properties;
328   SIMIX_request_push();
329   return req->process_create.result;
330 }
331
332 /** \brief Kills a SIMIX process.
333  *
334  * This function simply kills a  process.
335  *
336  * \param process poor victim
337  */
338 void SIMIX_req_process_kill(smx_process_t process)
339 {
340   smx_req_t req = SIMIX_req_mine();
341
342   req->call = REQ_PROCESS_KILL;
343   req->process_kill.process = process;
344   SIMIX_request_push();
345 }
346
347 /**
348  * \brief Migrates an agent to another location.
349  *
350  * This function changes the value of the host on which \a process is running.
351  *
352  * \param process the process to migrate
353  * \param source name of the previous host
354  * \param dest name of the new host
355  */
356 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
357 {
358   smx_req_t req = SIMIX_req_mine();
359
360   req->call = REQ_PROCESS_CHANGE_HOST;
361   req->process_change_host.process = process;
362   req->process_change_host.source = source;
363   req->process_change_host.dest = dest;
364   SIMIX_request_push();
365 }
366
367 /**
368  * \brief Suspends a process.
369  *
370  * This function suspends the process by suspending the action
371  * it was waiting for completion.
372  *
373  * \param process a SIMIX process
374  */
375 void SIMIX_req_process_suspend(smx_process_t process)
376 {
377   smx_req_t req = SIMIX_req_mine();
378
379   req->call = REQ_PROCESS_SUSPEND;
380   req->process_suspend.process = process;
381   SIMIX_request_push();
382 }
383
384 /**
385  * \brief Resumes a suspended process.
386  *
387  * This function resumes a suspended process by resuming the action
388  * it was waiting for completion.
389  *
390  * \param process a SIMIX process
391  */
392 void SIMIX_req_process_resume(smx_process_t process)
393 {
394   smx_req_t req = SIMIX_req_mine();
395
396   req->call = REQ_PROCESS_RESUME;
397   req->process_resume.process = process;
398   SIMIX_request_push();
399 }
400
401 /**
402  * \brief Returns the amount of SIMIX processes in the system
403  *
404  * Maestro internal process is not counted, only user code processes are
405  */
406 int SIMIX_req_process_count(void)
407 {
408   smx_req_t req = SIMIX_req_mine();
409
410   req->call = REQ_PROCESS_COUNT;
411   SIMIX_request_push();
412   return req->process_count.result;
413 }
414
415 /**
416  * \brief Return the user data of a #smx_process_t.
417  *
418  * This functions checks whether \a process is a valid pointer or not and return the user data associated to \a process if it is possible.
419  * \param process SIMIX process
420  * \return A void pointer to the user data
421  */
422 void* SIMIX_req_process_get_data(smx_process_t process)
423 {
424   smx_req_t req = SIMIX_req_mine();
425
426   req->call = REQ_PROCESS_GET_DATA;
427   req->process_get_data.process = process;
428   SIMIX_request_push();
429   return req->process_get_data.result;
430 }
431
432 /**
433  * \brief Set the user data of a #m_process_t.
434  *
435  * This functions checks whether \a process is a valid pointer or not and set the user data associated to \a process if it is possible.
436  * \param process SIMIX process
437  * \param data User data
438  */
439 void SIMIX_req_process_set_data(smx_process_t process, void *data)
440 {
441   smx_req_t req = SIMIX_req_mine();
442
443   req->call = REQ_PROCESS_SET_DATA;
444   req->process_set_data.process = process;
445   req->process_set_data.data = data;
446   SIMIX_request_push();
447 }
448
449 /**
450  * \brief Return the location on which an agent is running.
451  *
452  * This functions checks whether \a process is a valid pointer or not and return the m_host_t corresponding to the location on which \a process is running.
453  * \param process SIMIX process
454  * \return SIMIX host
455  */
456 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
457 {
458   smx_req_t req = SIMIX_req_mine();
459
460   req->call = REQ_PROCESS_GET_HOST;
461   req->process_get_host.process = process;
462   SIMIX_request_push();
463   return req->process_get_host.result;
464 }
465
466 /**
467  * \brief Return the name of an agent.
468  *
469  * This functions checks whether \a process is a valid pointer or not and return its name.
470  * \param process SIMIX process
471  * \return The process name
472  */
473 const char* SIMIX_req_process_get_name(smx_process_t process)
474 {
475   smx_req_t req = SIMIX_req_mine();
476
477   req->call = REQ_PROCESS_GET_NAME;
478   req->process_get_name.process = process;
479   SIMIX_request_push();
480   return req->process_get_name.result;
481 }
482
483 /**
484  * \brief Returns true if the process is suspended .
485  *
486  * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
487  * \param process SIMIX process
488  * \return 1, if the process is suspended, else 0.
489  */
490 int SIMIX_req_process_is_suspended(smx_process_t process)
491 {
492   smx_req_t req = SIMIX_req_mine();
493
494   req->call = REQ_PROCESS_IS_SUSPENDED;
495   req->process_is_suspended.process = process;
496   SIMIX_request_push();
497   return req->process_is_suspended.result;
498 }
499
500 /** \ingroup m_process_management
501  * \brief Return the properties
502  *
503  * This functions returns the properties associated with this process
504  */
505 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
506 {
507   smx_req_t req = SIMIX_req_mine();
508
509   req->call = REQ_PROCESS_GET_PROPERTIES;
510   req->process_get_properties.process = process;
511   SIMIX_request_push();
512   return req->process_get_properties.result;
513 }
514
515 /** \brief Creates a new sleep SIMIX action.
516  *
517  * This function creates a SURF action and allocates the data necessary
518  * to create the SIMIX action. It can raise a host_error exception if the
519  * host crashed. The default SIMIX name of the action is "sleep".
520  *
521  *      \param duration Time duration of the sleep.
522  *      \return A result telling whether the sleep was successful
523  */
524 e_smx_state_t SIMIX_req_process_sleep(double duration)
525 {
526   smx_req_t req = SIMIX_req_mine();
527
528   req->call = REQ_PROCESS_SLEEP;
529   req->process_sleep.duration = duration;
530   SIMIX_request_push();
531   return req->process_sleep.result;
532 }
533
534 /**
535  *  \brief Creates a new rendez-vous point
536  *  \param name The name of the rendez-vous point
537  *  \return The created rendez-vous point
538  */
539 smx_rdv_t SIMIX_req_rdv_create(const char *name)
540 {
541   smx_req_t req = SIMIX_req_mine();
542
543   req->call = REQ_RDV_CREATE;
544   req->rdv_create.name = name;
545
546   SIMIX_request_push();
547   return req->rdv_create.result;
548 }
549
550
551 /**
552  *  \brief Destroy a rendez-vous point
553  *  \param name The rendez-vous point to destroy
554  */
555 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
556 {
557   smx_req_t req = SIMIX_req_mine();
558
559   req->call = REQ_RDV_DESTROY;
560   req->rdv_destroy.rdv = rdv;
561
562   SIMIX_request_push();
563 }
564
565 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
566 {
567   xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
568   smx_req_t req = SIMIX_req_mine();
569
570   req->call = REQ_RDV_GEY_BY_NAME;
571   req->rdv_get_by_name.name = name;
572   SIMIX_request_push();
573   return req->rdv_get_by_name.result;
574 }
575
576 /**
577  *  \brief counts the number of communication requests of a given host pending
578  *         on a rendez-vous point
579  *  \param rdv The rendez-vous point
580  *  \param host The host to be counted
581  *  \return The number of comm request pending in the rdv
582  */
583 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
584 {
585   smx_req_t req = SIMIX_req_mine();
586
587   req->call = REQ_RDV_COMM_COUNT_BY_HOST;
588   req->rdv_comm_count_by_host.rdv = rdv;
589   req->rdv_comm_count_by_host.host = host;
590
591   SIMIX_request_push();
592   return req->rdv_comm_count_by_host.result;
593 }
594
595 /**
596  *  \brief returns the communication at the head of the rendez-vous
597  *  \param rdv The rendez-vous point
598  *  \return The communication or NULL if empty
599  */
600 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
601 {
602   smx_req_t req = SIMIX_req_mine();
603
604   req->call = REQ_RDV_GET_HEAD;
605   req->rdv_get_head.rdv = rdv;
606
607   SIMIX_request_push();
608   return req->rdv_get_head.result;
609 }
610
611 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
612                               void *src_buff, size_t src_buff_size,
613                               int (*match_fun)(void *, void *), void *data)
614 {
615   smx_req_t req = SIMIX_req_mine();
616
617   xbt_assert0(rdv, "No rendez-vous point defined for isend");
618
619   req->call = REQ_COMM_ISEND;
620   req->comm_isend.rdv = rdv;
621   req->comm_isend.task_size = task_size;
622   req->comm_isend.rate = rate;
623   req->comm_isend.src_buff = src_buff;
624   req->comm_isend.src_buff_size = src_buff_size;
625   req->comm_isend.match_fun = match_fun;
626   req->comm_isend.data = data;
627
628   SIMIX_request_push();
629   return req->comm_isend.result;
630 }
631
632 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
633                                                                   int (*match_fun)(void *, void *), void *data)
634 {
635   smx_req_t req = SIMIX_req_mine();
636
637   xbt_assert0(rdv, "No rendez-vous point defined for isend");
638
639   req->call = REQ_COMM_IRECV;
640   req->comm_irecv.rdv = rdv;
641   req->comm_irecv.dst_buff = dst_buff;
642   req->comm_irecv.dst_buff_size = dst_buff_size;
643   req->comm_irecv.match_fun = match_fun;
644   req->comm_irecv.data = data;
645
646   SIMIX_request_push();
647   return req->comm_irecv.result;
648 }
649
650 void SIMIX_req_comm_destroy(smx_action_t comm)
651 {
652   smx_req_t req = SIMIX_req_mine();
653
654   req->call = REQ_COMM_DESTROY;
655   req->comm_destroy.comm = comm;
656
657   SIMIX_request_push();
658 }
659
660 void SIMIX_req_comm_cancel(smx_action_t comm)
661 {
662   smx_req_t req = SIMIX_req_mine();
663
664   req->call = REQ_COMM_CANCEL;
665   req->comm_cancel.comm = comm;
666
667   SIMIX_request_push();
668 }
669
670 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
671 {
672   smx_req_t req = SIMIX_req_mine();
673
674   req->call = REQ_COMM_WAITANY;
675   req->comm_waitany.comms = comms;
676
677   SIMIX_request_push();
678   return req->comm_waitany.result;
679 }
680
681 int SIMIX_req_comm_testany(xbt_dynar_t comms)
682 {
683   smx_req_t req = SIMIX_req_mine();
684   if (xbt_dynar_length(comms)==0)
685     return -1;
686
687   req->call = REQ_COMM_TESTANY;
688   req->comm_testany.comms = comms;
689
690   SIMIX_request_push();
691   return req->comm_testany.result;
692 }
693
694 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
695 {
696   smx_req_t req = SIMIX_req_mine();
697
698   req->call = REQ_COMM_WAIT;
699   req->comm_wait.comm = comm;
700   req->comm_wait.timeout = timeout;
701
702   SIMIX_request_push();
703 }
704
705 #ifdef HAVE_TRACING
706 /**
707  * \brief Set the category of an action.
708  *
709  * This functions changes the category only. It calls a surf function.
710  * \param execution The execution action
711  * \param category The tracing category
712  */
713 void SIMIX_req_set_category(smx_action_t action, const char *category)
714 {
715   if (category == NULL) {
716     return;
717   }
718
719   smx_req_t req = SIMIX_req_mine();
720
721   req->call = REQ_SET_CATEGORY;
722   req->set_category.action = action;
723   req->set_category.category = category;
724
725   SIMIX_request_push();
726 }
727 #endif
728
729 int SIMIX_req_comm_test(smx_action_t comm)
730 {
731   smx_req_t req = SIMIX_req_mine();
732
733   req->call = REQ_COMM_TEST;
734   req->comm_test.comm = comm;
735
736   SIMIX_request_push();
737   return req->comm_test.result;
738 }
739
740 double SIMIX_req_comm_get_remains(smx_action_t comm)
741 {
742   smx_req_t req = SIMIX_req_mine();
743
744   req->call = REQ_COMM_GET_REMAINS;
745   req->comm_get_remains.comm = comm;
746
747   SIMIX_request_push();
748   return req->comm_get_remains.result;
749 }
750
751 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
752 {
753   smx_req_t req = SIMIX_req_mine();
754
755   req->call = REQ_COMM_GET_STATE;
756   req->comm_get_state.comm = comm;
757
758   SIMIX_request_push();
759   return req->comm_get_state.result;
760 }
761
762 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
763 {
764   smx_req_t req = SIMIX_req_mine();
765
766   req->call = REQ_COMM_GET_SRC_DATA;
767   req->comm_get_src_data.comm = comm;
768
769   SIMIX_request_push();
770   return req->comm_get_src_data.result;
771 }
772
773 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
774 {
775   smx_req_t req = SIMIX_req_mine();
776
777   req->call = REQ_COMM_GET_DST_DATA;
778   req->comm_get_dst_data.comm = comm;
779
780   SIMIX_request_push();
781   return req->comm_get_dst_data.result;
782 }
783
784 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
785 {
786   smx_req_t req = SIMIX_req_mine();
787
788   req->call = REQ_COMM_GET_SRC_BUFF;
789   req->comm_get_src_buff.comm = comm;
790
791   SIMIX_request_push();
792   return req->comm_get_src_buff.result;
793 }
794
795 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
796 {
797   smx_req_t req = SIMIX_req_mine();
798
799   req->call = REQ_COMM_GET_DST_BUFF;
800   req->comm_get_dst_buff.comm = comm;
801
802   SIMIX_request_push();
803   return req->comm_get_dst_buff.result;
804 }
805
806 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
807 {
808   smx_req_t req = SIMIX_req_mine();
809
810   req->call = REQ_COMM_GET_SRC_BUFF_SIZE;
811   req->comm_get_src_buff_size.comm = comm;
812
813   SIMIX_request_push();
814   return req->comm_get_src_buff_size.result;
815 }
816
817 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
818 {
819   smx_req_t req = SIMIX_req_mine();
820
821   req->call = REQ_COMM_GET_DST_BUFF_SIZE;
822   req->comm_get_dst_buff_size.comm = comm;
823
824   SIMIX_request_push();
825   return req->comm_get_dst_buff_size.result;
826 }
827
828 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
829 {
830   smx_req_t req = SIMIX_req_mine();
831
832   req->call = REQ_COMM_GET_SRC_PROC;
833   req->comm_get_src_proc.comm = comm;
834
835   SIMIX_request_push();
836   return req->comm_get_src_proc.result;
837 }
838
839 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
840 {
841   smx_req_t req = SIMIX_req_mine();
842
843   req->call = REQ_COMM_GET_DST_PROC;
844   req->comm_get_dst_proc.comm = comm;
845
846   SIMIX_request_push();
847   return req->comm_get_dst_proc.result;
848 }
849
850 #ifdef HAVE_LATENCY_BOUND_TRACKING
851 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
852 {
853   smx_req_t req = SIMIX_req_mine();
854
855   req->call = REQ_COMM_IS_LATENCY_BOUNDED;
856   req->comm_is_latency_bounded.comm = comm;
857
858   SIMIX_request_push();
859   return req->comm_is_latency_bounded.result;
860 }
861 #endif
862
863 smx_mutex_t SIMIX_req_mutex_init(void)
864 {
865   smx_req_t req = SIMIX_req_mine();
866
867   req->call = REQ_MUTEX_INIT;
868
869   SIMIX_request_push();
870   return req->mutex_init.result;
871 }
872
873 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
874 {
875   smx_req_t req = SIMIX_req_mine();
876
877   req->call = REQ_MUTEX_DESTROY;
878   req->mutex_destroy.mutex = mutex;
879
880   SIMIX_request_push();
881 }
882
883 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
884 {
885   smx_req_t req = SIMIX_req_mine();
886
887   req->call = REQ_MUTEX_LOCK;
888   req->mutex_lock.mutex = mutex;
889
890   SIMIX_request_push();
891 }
892
893 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
894 {
895   smx_req_t req = SIMIX_req_mine();
896
897   req->call = REQ_MUTEX_TRYLOCK;
898   req->mutex_trylock.mutex = mutex;
899
900   SIMIX_request_push();
901   return req->mutex_trylock.result;
902 }
903
904 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
905 {
906   smx_req_t req = SIMIX_req_mine();
907
908   req->call = REQ_MUTEX_UNLOCK;
909   req->mutex_unlock.mutex = mutex;
910
911   SIMIX_request_push();
912 }
913
914
915 smx_cond_t SIMIX_req_cond_init(void)
916 {
917   smx_req_t req = SIMIX_req_mine();
918
919   req->call = REQ_COND_INIT;
920
921   SIMIX_request_push();
922   return req->cond_init.result;
923 }
924
925 void SIMIX_req_cond_destroy(smx_cond_t cond)
926 {
927   smx_req_t req = SIMIX_req_mine();
928
929   req->call = REQ_COND_DESTROY;
930   req->cond_destroy.cond = cond;
931
932   SIMIX_request_push();
933 }
934
935 void SIMIX_req_cond_signal(smx_cond_t cond)
936 {
937   smx_req_t req = SIMIX_req_mine();
938
939   req->call = REQ_COND_SIGNAL;
940   req->cond_signal.cond = cond;
941
942   SIMIX_request_push();
943 }
944
945 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
946 {
947   smx_req_t req = SIMIX_req_mine();
948
949   req->call = REQ_COND_WAIT;
950   req->cond_wait.cond = cond;
951   req->cond_wait.mutex = mutex;
952
953   SIMIX_request_push();
954 }
955
956 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
957                                  smx_mutex_t mutex,
958                                  double timeout)
959 {
960   smx_req_t req = SIMIX_req_mine();
961
962   req->call = REQ_COND_WAIT_TIMEOUT;
963   req->cond_wait_timeout.cond = cond;
964   req->cond_wait_timeout.mutex = mutex;
965   req->cond_wait_timeout.timeout = timeout;
966
967   SIMIX_request_push();
968 }
969
970 void SIMIX_req_cond_broadcast(smx_cond_t cond)
971 {
972   smx_req_t req = SIMIX_req_mine();
973
974   req->call = REQ_COND_BROADCAST;
975   req->cond_broadcast.cond = cond;
976
977   SIMIX_request_push();
978 }
979
980
981 smx_sem_t SIMIX_req_sem_init(int capacity)
982 {
983   smx_req_t req = SIMIX_req_mine();
984
985   req->call = REQ_SEM_INIT;
986   req->sem_init.capacity = capacity;
987
988   SIMIX_request_push();
989   return req->sem_init.result;
990 }
991
992 void SIMIX_req_sem_destroy(smx_sem_t sem)
993 {
994   smx_req_t req = SIMIX_req_mine();
995
996   req->call = REQ_SEM_DESTROY;
997   req->sem_destroy.sem = sem;
998
999   SIMIX_request_push();
1000 }
1001
1002 void SIMIX_req_sem_release(smx_sem_t sem)
1003 {
1004   smx_req_t req = SIMIX_req_mine();
1005
1006   req->call = REQ_SEM_RELEASE;
1007   req->sem_release.sem = sem;
1008
1009   SIMIX_request_push();
1010 }
1011
1012 int SIMIX_req_sem_would_block(smx_sem_t sem)
1013 {
1014   smx_req_t req = SIMIX_req_mine();
1015
1016   req->call = REQ_SEM_WOULD_BLOCK;
1017   req->sem_would_block.sem = sem;
1018
1019   SIMIX_request_push();
1020   return req->sem_would_block.result;
1021 }
1022
1023 void SIMIX_req_sem_acquire(smx_sem_t sem)
1024 {
1025   smx_req_t req = SIMIX_req_mine();
1026
1027   req->call = REQ_SEM_ACQUIRE;
1028   req->sem_acquire.sem = sem;
1029
1030   SIMIX_request_push();
1031 }
1032
1033 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1034 {
1035   smx_req_t req = SIMIX_req_mine();
1036
1037   req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1038   req->sem_acquire_timeout.sem = sem;
1039   req->sem_acquire_timeout.timeout = timeout;
1040
1041   SIMIX_request_push();
1042 }
1043
1044 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1045 {
1046   smx_req_t req = SIMIX_req_mine();
1047
1048   req->call = REQ_SEM_GET_CAPACITY;
1049   req->sem_get_capacity.sem = sem;
1050
1051   SIMIX_request_push();
1052   return req->sem_get_capacity.result;
1053 }
1054 /* ************************************************************************** */
1055
1056 /** @brief returns a printable string representing the request kind */
1057 const char *SIMIX_request_name(int kind) {
1058   return request_names[kind];
1059 }