smx_mutex_t m = xbt_new0(s_smx_mutex_t, 1);
s_smx_process_t p; /* useful to initialize sleeping swag */
/* structures initialization */
- m->using = 0;
+ m->refcount = 0;
m->sleeping = xbt_swag_new(xbt_swag_offset(p, synchro_hookup));
return m;
}
xbt_assert0((mutex != NULL), "Invalid parameters");
- if (mutex->using) {
+ if (mutex->refcount ) {
/* somebody using the mutex, block */
xbt_swag_insert(self, mutex->sleeping);
self->simdata->mutex = mutex;
xbt_context_yield();
}
- mutex->using = 1;
+ mutex->refcount = 1;
} else {
/* mutex free */
- mutex->using = 1;
+ mutex->refcount = 1;
}
return;
}
{
xbt_assert0((mutex != NULL), "Invalid parameters");
- if (mutex->using)
+ if (mutex->refcount )
return 0;
else {
- mutex->using = 1;
+ mutex->refcount = 1;
return 1;
}
}
if (xbt_swag_size(mutex->sleeping) > 0) {
p = xbt_swag_extract(mutex->sleeping);
- mutex->using = 0;
+ mutex->refcount = 0;
xbt_swag_insert(p, simix_global->process_to_run);
} else {
/* nobody to wake up */
- mutex->using = 0;
+ mutex->refcount = 0;
}
return;
}