+ comments in log files
This commit is contained in:
parent
13a65c168c
commit
bf24d0aa0f
|
@ -16,7 +16,6 @@ package ewd123b
|
|||
import (
|
||||
"../controller"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
// global synchronization variables
|
||||
|
@ -40,7 +39,7 @@ L1:
|
|||
}
|
||||
//if the other process inspects c1 at this moment both will enter the critical section
|
||||
//we can force this behaviour if we wait for a moment
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
//time.Sleep(100 * time.Millisecond)
|
||||
|
||||
c1 = 0
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ package ewd123c
|
|||
|
||||
import (
|
||||
"../controller"
|
||||
"time"
|
||||
)
|
||||
|
||||
// global synchronization variables
|
||||
|
@ -34,7 +33,7 @@ A1:
|
|||
L1:
|
||||
//if process 2 inspects c1 at this moment, both processes will wait for each other to set cX.
|
||||
//we can force this behavior if we wait for a moment
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
//time.Sleep(100 * time.Millisecond)
|
||||
if c2 == 0 {
|
||||
goto L1
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
2020/03/11 16:10:15.212947 ewd123.go:33: *** Start Prozesse wechseln sich immer nur ab (Reihenfolge immer 1,2,1,2,1,2,1,2,...)
|
||||
2020/03/11 16:10:15.325177 controller.go:32: entered CS: 1 Dies führt zu einem Deadlock wenn einer der Prozesse abstürzt.
|
||||
2020/03/11 16:10:15.325177 controller.go:32: entered CS: 1 Dies führt zu einem Deadlock wenn einer der Prozesse abstürzt, da der andere warten muss bis CS freigegeben ist.
|
||||
2020/03/11 16:10:15.325177 controller.go:57: inside CS: 1 (50 msecs)
|
||||
2020/03/11 16:10:15.376074 controller.go:47: left CS: 1
|
||||
2020/03/11 16:10:15.376074 controller.go:67: outside CS: 1 (100 msecs)
|
||||
|
|
|
@ -3,12 +3,9 @@
|
|||
2020/03/11 16:13:30.435731 controller.go:57: inside CS: 2 (50 msecs)
|
||||
2020/03/11 16:13:30.486109 controller.go:47: left CS: 2
|
||||
2020/03/11 16:13:30.486109 controller.go:67: outside CS: 2 (100 msecs)
|
||||
2020/03/11 16:13:30.586466 controller.go:32: entered CS: 2
|
||||
2020/03/11 16:13:30.586466 controller.go:57: inside CS: 2 (50 msecs)
|
||||
2020/03/11 16:13:30.586466 controller.go:29: Process 1 tried to enter the critical section while it was already occupied by: 2
|
||||
2020/03/11 16:13:30.586466 controller.go:32: entered CS: 2 process1 inspiziert c2
|
||||
2020/03/11 16:13:30.586466 controller.go:57: inside CS: 2 (50 msecs) process1 schläft & process2 ändert c2
|
||||
2020/03/11 16:13:30.586466 controller.go:29: Process 1 tried to enter the critical section while it was already occupied by: 2 process1 versucht cs zu betreten.
|
||||
|
||||
Process finished with exit code 1
|
||||
|
||||
|
||||
Inspiziert ein Prozess die Statusvariable des anderen bevor dieser diese ändert, aber nachdem dieser die des anderen inspiziert,
|
||||
versuchen beide Prozesse gleichzeitig in die Kritische Sektion zu wechseln.
|
|
@ -2,7 +2,7 @@
|
|||
2020/03/11 16:13:55.173331 controller.go:32: entered CS: 2
|
||||
2020/03/11 16:13:55.173331 controller.go:57: inside CS: 2 (50 msecs)
|
||||
2020/03/11 16:13:55.224196 controller.go:47: left CS: 2
|
||||
2020/03/11 16:13:55.224196 controller.go:67: outside CS: 2 (100 msecs)
|
||||
2020/03/11 16:13:55.224196 controller.go:67: outside CS: 2 (100 msecs) process2 inspiziert c1 & process1 inspiziert c2 mit leichter Verzögerung
|
||||
2020/03/11 16:13:55.274062 controller.go:32: entered CS: 1
|
||||
2020/03/11 16:13:55.274062 controller.go:57: inside CS: 1 (50 msecs)
|
||||
2020/03/11 16:13:55.324931 controller.go:47: left CS: 1
|
||||
|
@ -12,3 +12,5 @@
|
|||
2020/03/11 16:13:55.375434 controller.go:47: left CS: 2
|
||||
2020/03/11 16:13:55.375434 controller.go:67: outside CS: 2 (100 msecs)
|
||||
|
||||
beide Prozesse warten jetzt bis der jeweils andere ihr c auf 1 setzt,
|
||||
somit entsteht ein Livelock
|
|
@ -40,4 +40,7 @@
|
|||
fatal error: all goroutines are asleep - deadlock!
|
||||
|
||||
goroutine 1 [chan receive]:
|
||||
main.main()
|
||||
main.main()
|
||||
|
||||
beide Prozesse müssen cX im genau gleichen Moment inspizieren um hier einen Livelock auszulösen
|
||||
Dies benötigt ein exaxtes Timing welches schwierig ist zu reproduzieren.
|
Loading…
Reference in New Issue