Logo AND Algorithmique Numérique Distribuée

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