Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
163a7d47f8b5c5a0bae4aeec2f34132f2ccef2e8
[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.
283  *
284  * \param execution The execution action
285  */
286 void 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 }
294
295 /**
296  * \brief Creates and runs a new SIMIX process.
297  *
298  * The structure and the corresponding threada are created and put in the list of ready processes.
299  *
300  * \param name a name for the process. It is for user-level information and can be NULL.
301  * \param code the main function of the process
302  * \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.
303  * It can be retrieved with the function \ref SIMIX_req_process_get_data.
304  * \param hostname name of the host where the new agent is executed.
305  * \param argc first argument passed to \a code
306  * \param argv second argument passed to \a code
307  * \param properties the properties of the process
308  * \return The new process
309  */
310 smx_process_t SIMIX_req_process_create(const char *name,
311                                    xbt_main_func_t code,
312                                    void *data,
313                                    const char *hostname,
314                                    int argc, char **argv,
315                                    xbt_dict_t properties)
316 {
317   smx_req_t req = SIMIX_req_mine();
318
319   req->call = REQ_PROCESS_CREATE;
320   req->process_create.name = name;
321   req->process_create.code = code;
322   req->process_create.data = data;
323   req->process_create.hostname = hostname;
324   req->process_create.argc = argc;
325   req->process_create.argv = argv;
326   req->process_create.properties = properties;
327   SIMIX_request_push();
328   return req->process_create.result;
329 }
330
331 /** \brief Kills a SIMIX process.
332  *
333  * This function simply kills a  process.
334  *
335  * \param process poor victim
336  */
337 void SIMIX_req_process_kill(smx_process_t process)
338 {
339   smx_req_t req = SIMIX_req_mine();
340
341   req->call = REQ_PROCESS_KILL;
342   req->process_kill.process = process;
343   SIMIX_request_push();
344 }
345
346 /**
347  * \brief Migrates an agent to another location.
348  *
349  * This function changes the value of the host on which \a process is running.
350  *
351  * \param process the process to migrate
352  * \param source name of the previous host
353  * \param dest name of the new host
354  */
355 void SIMIX_req_process_change_host(smx_process_t process, const char *source, const char *dest)
356 {
357   smx_req_t req = SIMIX_req_mine();
358
359   req->call = REQ_PROCESS_CHANGE_HOST;
360   req->process_change_host.process = process;
361   req->process_change_host.source = source;
362   req->process_change_host.dest = dest;
363   SIMIX_request_push();
364 }
365
366 /**
367  * \brief Suspends a process.
368  *
369  * This function suspends the process by suspending the action
370  * it was waiting for completion.
371  *
372  * \param process a SIMIX process
373  */
374 void SIMIX_req_process_suspend(smx_process_t process)
375 {
376   smx_req_t req = SIMIX_req_mine();
377
378   req->call = REQ_PROCESS_SUSPEND;
379   req->process_suspend.process = process;
380   SIMIX_request_push();
381 }
382
383 /**
384  * \brief Resumes a suspended process.
385  *
386  * This function resumes a suspended process by resuming the action
387  * it was waiting for completion.
388  *
389  * \param process a SIMIX process
390  */
391 void SIMIX_req_process_resume(smx_process_t process)
392 {
393   smx_req_t req = SIMIX_req_mine();
394
395   req->call = REQ_PROCESS_RESUME;
396   req->process_resume.process = process;
397   SIMIX_request_push();
398 }
399
400 /**
401  * \brief Returns the amount of SIMIX processes in the system
402  *
403  * Maestro internal process is not counted, only user code processes are
404  */
405 int SIMIX_req_process_count(void)
406 {
407   smx_req_t req = SIMIX_req_mine();
408
409   req->call = REQ_PROCESS_COUNT;
410   SIMIX_request_push();
411   return req->process_count.result;
412 }
413
414 /**
415  * \brief Return the user data of a #smx_process_t.
416  *
417  * 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.
418  * \param process SIMIX process
419  * \return A void pointer to the user data
420  */
421 void* SIMIX_req_process_get_data(smx_process_t process)
422 {
423   smx_req_t req = SIMIX_req_mine();
424
425   req->call = REQ_PROCESS_GET_DATA;
426   req->process_get_data.process = process;
427   SIMIX_request_push();
428   return req->process_get_data.result;
429 }
430
431 /**
432  * \brief Set the user data of a #m_process_t.
433  *
434  * 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.
435  * \param process SIMIX process
436  * \param data User data
437  */
438 void SIMIX_req_process_set_data(smx_process_t process, void *data)
439 {
440   smx_req_t req = SIMIX_req_mine();
441
442   req->call = REQ_PROCESS_SET_DATA;
443   req->process_set_data.process = process;
444   req->process_set_data.data = data;
445   SIMIX_request_push();
446 }
447
448 /**
449  * \brief Return the location on which an agent is running.
450  *
451  * 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.
452  * \param process SIMIX process
453  * \return SIMIX host
454  */
455 smx_host_t SIMIX_req_process_get_host(smx_process_t process)
456 {
457   smx_req_t req = SIMIX_req_mine();
458
459   req->call = REQ_PROCESS_GET_HOST;
460   req->process_get_host.process = process;
461   SIMIX_request_push();
462   return req->process_get_host.result;
463 }
464
465 /**
466  * \brief Return the name of an agent.
467  *
468  * This functions checks whether \a process is a valid pointer or not and return its name.
469  * \param process SIMIX process
470  * \return The process name
471  */
472 const char* SIMIX_req_process_get_name(smx_process_t process)
473 {
474   smx_req_t req = SIMIX_req_mine();
475
476   req->call = REQ_PROCESS_GET_NAME;
477   req->process_get_name.process = process;
478   SIMIX_request_push();
479   return req->process_get_name.result;
480 }
481
482 /**
483  * \brief Returns true if the process is suspended .
484  *
485  * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
486  * \param process SIMIX process
487  * \return 1, if the process is suspended, else 0.
488  */
489 int SIMIX_req_process_is_suspended(smx_process_t process)
490 {
491   smx_req_t req = SIMIX_req_mine();
492
493   req->call = REQ_PROCESS_IS_SUSPENDED;
494   req->process_is_suspended.process = process;
495   SIMIX_request_push();
496   return req->process_is_suspended.result;
497 }
498
499 /** \ingroup m_process_management
500  * \brief Return the properties
501  *
502  * This functions returns the properties associated with this process
503  */
504 xbt_dict_t SIMIX_req_process_get_properties(smx_process_t process)
505 {
506   smx_req_t req = SIMIX_req_mine();
507
508   req->call = REQ_PROCESS_GET_PROPERTIES;
509   req->process_get_properties.process = process;
510   SIMIX_request_push();
511   return req->process_get_properties.result;
512 }
513
514 /** \brief Creates a new sleep SIMIX action.
515  *
516  * This function creates a SURF action and allocates the data necessary
517  * to create the SIMIX action. It can raise a host_error exception if the
518  * host crashed. The default SIMIX name of the action is "sleep".
519  *
520  *      \param duration Time duration of the sleep.
521  *      \return A result telling whether the sleep was successful
522  */
523 e_smx_state_t SIMIX_req_process_sleep(double duration)
524 {
525   smx_req_t req = SIMIX_req_mine();
526
527   req->call = REQ_PROCESS_SLEEP;
528   req->process_sleep.duration = duration;
529   SIMIX_request_push();
530   return req->process_sleep.result;
531 }
532
533 /**
534  *  \brief Creates a new rendez-vous point
535  *  \param name The name of the rendez-vous point
536  *  \return The created rendez-vous point
537  */
538 smx_rdv_t SIMIX_req_rdv_create(const char *name)
539 {
540   smx_req_t req = SIMIX_req_mine();
541
542   req->call = REQ_RDV_CREATE;
543   req->rdv_create.name = name;
544
545   SIMIX_request_push();
546   return req->rdv_create.result;
547 }
548
549
550 /**
551  *  \brief Destroy a rendez-vous point
552  *  \param name The rendez-vous point to destroy
553  */
554 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
555 {
556   smx_req_t req = SIMIX_req_mine();
557
558   req->call = REQ_RDV_DESTROY;
559   req->rdv_destroy.rdv = rdv;
560
561   SIMIX_request_push();
562 }
563
564 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
565 {
566   xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
567   smx_req_t req = SIMIX_req_mine();
568
569   req->call = REQ_RDV_GEY_BY_NAME;
570   req->rdv_get_by_name.name = name;
571   SIMIX_request_push();
572   return req->rdv_get_by_name.result;
573 }
574
575 /**
576  *  \brief counts the number of communication requests of a given host pending
577  *         on a rendez-vous point
578  *  \param rdv The rendez-vous point
579  *  \param host The host to be counted
580  *  \return The number of comm request pending in the rdv
581  */
582 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
583 {
584   smx_req_t req = SIMIX_req_mine();
585
586   req->call = REQ_RDV_COMM_COUNT_BY_HOST;
587   req->rdv_comm_count_by_host.rdv = rdv;
588   req->rdv_comm_count_by_host.host = host;
589
590   SIMIX_request_push();
591   return req->rdv_comm_count_by_host.result;
592 }
593
594 /**
595  *  \brief returns the communication at the head of the rendez-vous
596  *  \param rdv The rendez-vous point
597  *  \return The communication or NULL if empty
598  */
599 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
600 {
601   smx_req_t req = SIMIX_req_mine();
602
603   req->call = REQ_RDV_GET_HEAD;
604   req->rdv_get_head.rdv = rdv;
605
606   SIMIX_request_push();
607   return req->rdv_get_head.result;
608 }
609
610 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
611                               void *src_buff, size_t src_buff_size,
612                               int (*match_fun)(void *, void *), void *data)
613 {
614   smx_req_t req = SIMIX_req_mine();
615
616   xbt_assert0(rdv, "No rendez-vous point defined for isend");
617
618   req->call = REQ_COMM_ISEND;
619   req->comm_isend.rdv = rdv;
620   req->comm_isend.task_size = task_size;
621   req->comm_isend.rate = rate;
622   req->comm_isend.src_buff = src_buff;
623   req->comm_isend.src_buff_size = src_buff_size;
624   req->comm_isend.match_fun = match_fun;
625   req->comm_isend.data = data;
626
627   SIMIX_request_push();
628   return req->comm_isend.result;
629 }
630
631 smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
632                                                                   int (*match_fun)(void *, void *), void *data)
633 {
634   smx_req_t req = SIMIX_req_mine();
635
636   xbt_assert0(rdv, "No rendez-vous point defined for isend");
637
638   req->call = REQ_COMM_IRECV;
639   req->comm_irecv.rdv = rdv;
640   req->comm_irecv.dst_buff = dst_buff;
641   req->comm_irecv.dst_buff_size = dst_buff_size;
642   req->comm_irecv.match_fun = match_fun;
643   req->comm_irecv.data = data;
644
645   SIMIX_request_push();
646   return req->comm_irecv.result;
647 }
648
649 void SIMIX_req_comm_destroy(smx_action_t comm)
650 {
651   smx_req_t req = SIMIX_req_mine();
652
653   req->call = REQ_COMM_DESTROY;
654   req->comm_destroy.comm = comm;
655
656   SIMIX_request_push();
657 }
658
659 void SIMIX_req_comm_cancel(smx_action_t comm)
660 {
661   smx_req_t req = SIMIX_req_mine();
662
663   req->call = REQ_COMM_CANCEL;
664   req->comm_cancel.comm = comm;
665
666   SIMIX_request_push();
667 }
668
669 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
670 {
671   smx_req_t req = SIMIX_req_mine();
672
673   req->call = REQ_COMM_WAITANY;
674   req->comm_waitany.comms = comms;
675
676   SIMIX_request_push();
677   return req->comm_waitany.result;
678 }
679
680 int SIMIX_req_comm_testany(xbt_dynar_t comms)
681 {
682   smx_req_t req = SIMIX_req_mine();
683   if (xbt_dynar_length(comms)==0)
684     return -1;
685
686   req->call = REQ_COMM_TESTANY;
687   req->comm_testany.comms = comms;
688
689   SIMIX_request_push();
690   return req->comm_testany.result;
691 }
692
693 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
694 {
695   smx_req_t req = SIMIX_req_mine();
696
697   req->call = REQ_COMM_WAIT;
698   req->comm_wait.comm = comm;
699   req->comm_wait.timeout = timeout;
700
701   SIMIX_request_push();
702 }
703
704 #ifdef HAVE_TRACING
705 /**
706  * \brief Set the category of an action.
707  *
708  * This functions changes the category only. It calls a surf function.
709  * \param execution The execution action
710  * \param category The tracing category
711  */
712 void SIMIX_req_set_category(smx_action_t action, const char *category)
713 {
714   if (category == NULL) {
715     return;
716   }
717
718   smx_req_t req = SIMIX_req_mine();
719
720   req->call = REQ_SET_CATEGORY;
721   req->set_category.action = action;
722   req->set_category.category = category;
723
724   SIMIX_request_push();
725 }
726 #endif
727
728 int SIMIX_req_comm_test(smx_action_t comm)
729 {
730   smx_req_t req = SIMIX_req_mine();
731
732   req->call = REQ_COMM_TEST;
733   req->comm_test.comm = comm;
734
735   SIMIX_request_push();
736   return req->comm_test.result;
737 }
738
739 double SIMIX_req_comm_get_remains(smx_action_t comm)
740 {
741   smx_req_t req = SIMIX_req_mine();
742
743   req->call = REQ_COMM_GET_REMAINS;
744   req->comm_get_remains.comm = comm;
745
746   SIMIX_request_push();
747   return req->comm_get_remains.result;
748 }
749
750 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
751 {
752   smx_req_t req = SIMIX_req_mine();
753
754   req->call = REQ_COMM_GET_STATE;
755   req->comm_get_state.comm = comm;
756
757   SIMIX_request_push();
758   return req->comm_get_state.result;
759 }
760
761 void *SIMIX_req_comm_get_src_data(smx_action_t comm)
762 {
763   smx_req_t req = SIMIX_req_mine();
764
765   req->call = REQ_COMM_GET_SRC_DATA;
766   req->comm_get_src_data.comm = comm;
767
768   SIMIX_request_push();
769   return req->comm_get_src_data.result;
770 }
771
772 void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
773 {
774   smx_req_t req = SIMIX_req_mine();
775
776   req->call = REQ_COMM_GET_DST_DATA;
777   req->comm_get_dst_data.comm = comm;
778
779   SIMIX_request_push();
780   return req->comm_get_dst_data.result;
781 }
782
783 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
784 {
785   smx_req_t req = SIMIX_req_mine();
786
787   req->call = REQ_COMM_GET_SRC_BUFF;
788   req->comm_get_src_buff.comm = comm;
789
790   SIMIX_request_push();
791   return req->comm_get_src_buff.result;
792 }
793
794 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
795 {
796   smx_req_t req = SIMIX_req_mine();
797
798   req->call = REQ_COMM_GET_DST_BUFF;
799   req->comm_get_dst_buff.comm = comm;
800
801   SIMIX_request_push();
802   return req->comm_get_dst_buff.result;
803 }
804
805 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
806 {
807   smx_req_t req = SIMIX_req_mine();
808
809   req->call = REQ_COMM_GET_SRC_BUFF_SIZE;
810   req->comm_get_src_buff_size.comm = comm;
811
812   SIMIX_request_push();
813   return req->comm_get_src_buff_size.result;
814 }
815
816 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
817 {
818   smx_req_t req = SIMIX_req_mine();
819
820   req->call = REQ_COMM_GET_DST_BUFF_SIZE;
821   req->comm_get_dst_buff_size.comm = comm;
822
823   SIMIX_request_push();
824   return req->comm_get_dst_buff_size.result;
825 }
826
827 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
828 {
829   smx_req_t req = SIMIX_req_mine();
830
831   req->call = REQ_COMM_GET_SRC_PROC;
832   req->comm_get_src_proc.comm = comm;
833
834   SIMIX_request_push();
835   return req->comm_get_src_proc.result;
836 }
837
838 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
839 {
840   smx_req_t req = SIMIX_req_mine();
841
842   req->call = REQ_COMM_GET_DST_PROC;
843   req->comm_get_dst_proc.comm = comm;
844
845   SIMIX_request_push();
846   return req->comm_get_dst_proc.result;
847 }
848
849 #ifdef HAVE_LATENCY_BOUND_TRACKING
850 int SIMIX_req_comm_is_latency_bounded(smx_action_t comm)
851 {
852   smx_req_t req = SIMIX_req_mine();
853
854   req->call = REQ_COMM_IS_LATENCY_BOUNDED;
855   req->comm_is_latency_bounded.comm = comm;
856
857   SIMIX_request_push();
858   return req->comm_is_latency_bounded.result;
859 }
860 #endif
861
862 smx_mutex_t SIMIX_req_mutex_init(void)
863 {
864   smx_req_t req = SIMIX_req_mine();
865
866   req->call = REQ_MUTEX_INIT;
867
868   SIMIX_request_push();
869   return req->mutex_init.result;
870 }
871
872 void SIMIX_req_mutex_destroy(smx_mutex_t mutex)
873 {
874   smx_req_t req = SIMIX_req_mine();
875
876   req->call = REQ_MUTEX_DESTROY;
877   req->mutex_destroy.mutex = mutex;
878
879   SIMIX_request_push();
880 }
881
882 void SIMIX_req_mutex_lock(smx_mutex_t mutex)
883 {
884   smx_req_t req = SIMIX_req_mine();
885
886   req->call = REQ_MUTEX_LOCK;
887   req->mutex_lock.mutex = mutex;
888
889   SIMIX_request_push();
890 }
891
892 int SIMIX_req_mutex_trylock(smx_mutex_t mutex)
893 {
894   smx_req_t req = SIMIX_req_mine();
895
896   req->call = REQ_MUTEX_TRYLOCK;
897   req->mutex_trylock.mutex = mutex;
898
899   SIMIX_request_push();
900   return req->mutex_trylock.result;
901 }
902
903 void SIMIX_req_mutex_unlock(smx_mutex_t mutex)
904 {
905   smx_req_t req = SIMIX_req_mine();
906
907   req->call = REQ_MUTEX_UNLOCK;
908   req->mutex_unlock.mutex = mutex;
909
910   SIMIX_request_push();
911 }
912
913
914 smx_cond_t SIMIX_req_cond_init(void)
915 {
916   smx_req_t req = SIMIX_req_mine();
917
918   req->call = REQ_COND_INIT;
919
920   SIMIX_request_push();
921   return req->cond_init.result;
922 }
923
924 void SIMIX_req_cond_destroy(smx_cond_t cond)
925 {
926   smx_req_t req = SIMIX_req_mine();
927
928   req->call = REQ_COND_DESTROY;
929   req->cond_destroy.cond = cond;
930
931   SIMIX_request_push();
932 }
933
934 void SIMIX_req_cond_signal(smx_cond_t cond)
935 {
936   smx_req_t req = SIMIX_req_mine();
937
938   req->call = REQ_COND_SIGNAL;
939   req->cond_signal.cond = cond;
940
941   SIMIX_request_push();
942 }
943
944 void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
945 {
946   smx_req_t req = SIMIX_req_mine();
947
948   req->call = REQ_COND_WAIT;
949   req->cond_wait.cond = cond;
950   req->cond_wait.mutex = mutex;
951
952   SIMIX_request_push();
953 }
954
955 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
956                                  smx_mutex_t mutex,
957                                  double timeout)
958 {
959   smx_req_t req = SIMIX_req_mine();
960
961   req->call = REQ_COND_WAIT_TIMEOUT;
962   req->cond_wait_timeout.cond = cond;
963   req->cond_wait_timeout.mutex = mutex;
964   req->cond_wait_timeout.timeout = timeout;
965
966   SIMIX_request_push();
967 }
968
969 void SIMIX_req_cond_broadcast(smx_cond_t cond)
970 {
971   smx_req_t req = SIMIX_req_mine();
972
973   req->call = REQ_COND_BROADCAST;
974   req->cond_broadcast.cond = cond;
975
976   SIMIX_request_push();
977 }
978
979
980 smx_sem_t SIMIX_req_sem_init(int capacity)
981 {
982   smx_req_t req = SIMIX_req_mine();
983
984   req->call = REQ_SEM_INIT;
985   req->sem_init.capacity = capacity;
986
987   SIMIX_request_push();
988   return req->sem_init.result;
989 }
990
991 void SIMIX_req_sem_destroy(smx_sem_t sem)
992 {
993   smx_req_t req = SIMIX_req_mine();
994
995   req->call = REQ_SEM_DESTROY;
996   req->sem_destroy.sem = sem;
997
998   SIMIX_request_push();
999 }
1000
1001 void SIMIX_req_sem_release(smx_sem_t sem)
1002 {
1003   smx_req_t req = SIMIX_req_mine();
1004
1005   req->call = REQ_SEM_RELEASE;
1006   req->sem_release.sem = sem;
1007
1008   SIMIX_request_push();
1009 }
1010
1011 int SIMIX_req_sem_would_block(smx_sem_t sem)
1012 {
1013   smx_req_t req = SIMIX_req_mine();
1014
1015   req->call = REQ_SEM_WOULD_BLOCK;
1016   req->sem_would_block.sem = sem;
1017
1018   SIMIX_request_push();
1019   return req->sem_would_block.result;
1020 }
1021
1022 void SIMIX_req_sem_acquire(smx_sem_t sem)
1023 {
1024   smx_req_t req = SIMIX_req_mine();
1025
1026   req->call = REQ_SEM_ACQUIRE;
1027   req->sem_acquire.sem = sem;
1028
1029   SIMIX_request_push();
1030 }
1031
1032 void SIMIX_req_sem_acquire_timeout(smx_sem_t sem, double timeout)
1033 {
1034   smx_req_t req = SIMIX_req_mine();
1035
1036   req->call = REQ_SEM_ACQUIRE_TIMEOUT;
1037   req->sem_acquire_timeout.sem = sem;
1038   req->sem_acquire_timeout.timeout = timeout;
1039
1040   SIMIX_request_push();
1041 }
1042
1043 int SIMIX_req_sem_get_capacity(smx_sem_t sem)
1044 {
1045   smx_req_t req = SIMIX_req_mine();
1046
1047   req->call = REQ_SEM_GET_CAPACITY;
1048   req->sem_get_capacity.sem = sem;
1049
1050   SIMIX_request_push();
1051   return req->sem_get_capacity.result;
1052 }
1053 /* ************************************************************************** */
1054
1055 /** @brief returns a printable string representing the request kind */
1056 const char *SIMIX_request_name(int kind) {
1057   return request_names[kind];
1058 }