Logo AND Algorithmique Numérique Distribuée

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