if (process != SIMIX_process_self()) {
- if (process->mutex) {
- /* process blocked on a mutex, only set suspend=1 */
+ if (process->mutex || process->sem) {
+ /* process blocked on a mutex or sem, only set suspend=1 */
process->suspended = 1;
} else if (process->cond) {
/* process blocked cond, suspend all actions */
if (process == SIMIX_process_self())
return;
- if (process->mutex) {
- DEBUG0("Resume process blocked on a mutex");
+ if (process->mutex || process->sem) {
+ DEBUG0("Resume process blocked on a mutex or semaphore");
process->suspended = 0; /* It'll wake up by itself when mutex releases */
return;
} else if (process->cond) {
xbt_swag_insert(self, sem->sleeping);
}
SIMIX_process_yield();
+ self->sem = NULL;
while (self->suspended)
SIMIX_process_yield();
/* one of the semaphore unsuspended us -- great, let's search which one (and get out of the others) */
- self->sem = NULL;
xbt_dynar_foreach(sems,counter,sem) {
if (xbt_swag_belongs(self,sem->sleeping))
xbt_swag_remove(self,sem->sleeping);