Logo AND Algorithmique Numérique Distribuée

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