Apuntes
Livelock
Contenido del apunte (1)
Página 1
In some situations, a process tries to be polite by giving up the locks it already acquired whenever it noticed that it cannot obtain the next lock it needs.
Then waits a millisecond, say, and tries again.
In principle, this is good and should help to detect and avoid deadlock.
However, if the other process does the same thing at exactly the same time, they will be in the situation of two people trying to pass each other on the street when both of them politely step aside, and yet no progress is possible, because they keep stepping the same way at the same time.
void process_A(void) {
acquire_lock(&resource_1);
while (try_lock(&resource_2) == FAIL) {
release_lock(&resource_1);
wait_fixed_time();
acquire_lock(&resource_1);
}
use_both_resources();
release_lock(&resource_2);
release_lock(&resource_1);
}
void process_B(void) {
acquire_lock(&resource_2);
while (try_lock(&resource_1) == FAIL) {
release_lock(&resource_2);
wait_fixed_time();
acquire_lock(&resource_2);
}
use_both_resources();
release_lock(&resource_1);
release_lock(&resource_2);
}
Información
- Descripción
- 0 (Deadlock) Operating Systems Apunte sobre Livelock, creado por Ahmad Abdelwahed el 26/06/2015.
- Creado por
- Ahmad Abdelwahed
- Visitas
- 4
- Etiquetas
- Valoración