- simdata_process_t simdata = NULL;
-
- xbt_assert0(((process) && (process->simdata)), "Invalid parameters");
-
- if(process!=SIMIX_process_self()) {
- simdata = process->simdata;
-
- if (simdata->mutex) {
- /* process blocked on a mutex, only set suspend=1 */
- simdata->suspended = 1;
- }
- else if (simdata->cond){
- /* process blocked cond, suspend all actions */
-
- /* temporaries variables */
- smx_cond_t c;
- xbt_fifo_item_t i;
- smx_action_t act;
-
- simdata->suspended = 1;
- c = simdata->cond;
- xbt_fifo_foreach(c->actions,i,act, smx_action_t) {
- surf_workstation_resource->common_public->suspend(act->simdata->surf_action);
- }
- }
- else {
- simdata->suspended = 1;
- }
+ xbt_assert0(process, "Invalid parameters");
+
+ if (process != SIMIX_process_self()) {
+
+ if (process->mutex) {
+ /* process blocked on a mutex or sem, only set suspend=1 */
+ process->suspended = 1;
+ } else if (process->cond) {
+ /* process blocked cond, suspend all actions */
+
+ /* temporaries variables */
+ smx_cond_t c;
+ xbt_fifo_item_t i;
+ smx_action_t act;
+
+ process->suspended = 1;
+ c = process->cond;
+ xbt_fifo_foreach(c->actions, i, act, smx_action_t) {
+ SIMIX_action_suspend(act);
+ }
+ } else if (process->sem) {
+ smx_sem_t s;
+ xbt_fifo_item_t i;
+ smx_action_t act;
+
+ process->suspended = 1;
+ s = process->sem;
+ xbt_fifo_foreach(s->actions, i, act, smx_action_t) {
+ SIMIX_action_suspend(act);
+ }
+ } else {
+ process->suspended = 1;
+ }
+ } else {
+ /* process executing, I can create an action and suspend it */
+ smx_action_t dummy;
+ smx_cond_t cond;
+ char name[] = "dummy";
+ process->suspended = 1;
+
+ cond = SIMIX_cond_init();
+ dummy = SIMIX_action_execute(SIMIX_process_get_host(process), name, 0);
+ SIMIX_process_self()->waiting_action = dummy;
+ SIMIX_action_suspend(dummy);
+ SIMIX_register_action_to_condition(dummy, cond);
+ __SIMIX_cond_wait(cond);
+ SIMIX_process_self()->waiting_action = NULL;
+ SIMIX_unregister_action_to_condition(dummy, cond);
+ SIMIX_action_destroy(dummy);
+ SIMIX_cond_destroy(cond);