Logo AND Algorithmique Numérique Distribuée

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