Notizen
Livelock
Inhalt der Notizen (1)
Seite 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);
}
Informationen
- Beschreibung
- 0 Operating Systems (Deadlock) Notiz am Livelock, erstellt von Ahmad Abdelwahed am 26/06/2015.
- Erstellt von
- Ahmad Abdelwahed · Jun 2015
- Aktualisiert
- 19 Feb 2016
- Aufrufe
- 4
- Tags
- Bewertung