+ comments in log files

This commit is contained in:
Johannes Theiner 2020-03-24 15:59:30 +01:00
parent 13a65c168c
commit bf24d0aa0f
6 changed files with 13 additions and 13 deletions

View File

@ -16,7 +16,6 @@ package ewd123b
import ( import (
"../controller" "../controller"
"log" "log"
"time"
) )
// global synchronization variables // global synchronization variables
@ -40,7 +39,7 @@ L1:
} }
//if the other process inspects c1 at this moment both will enter the critical section //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 //we can force this behaviour if we wait for a moment
time.Sleep(100 * time.Millisecond) //time.Sleep(100 * time.Millisecond)
c1 = 0 c1 = 0

View File

@ -15,7 +15,6 @@ package ewd123c
import ( import (
"../controller" "../controller"
"time"
) )
// global synchronization variables // global synchronization variables
@ -34,7 +33,7 @@ A1:
L1: L1:
//if process 2 inspects c1 at this moment, both processes will wait for each other to set cX. //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 //we can force this behavior if we wait for a moment
time.Sleep(100 * time.Millisecond) //time.Sleep(100 * time.Millisecond)
if c2 == 0 { if c2 == 0 {
goto L1 goto L1
} }

View File

@ -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.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.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:47: left CS: 1
2020/03/11 16:10:15.376074 controller.go:67: outside CS: 1 (100 msecs) 2020/03/11 16:10:15.376074 controller.go:67: outside CS: 1 (100 msecs)

View File

@ -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.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: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.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:32: entered CS: 2 process1 inspiziert c2
2020/03/11 16:13:30.586466 controller.go:57: inside CS: 2 (50 msecs) 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 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 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.

View File

@ -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: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.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: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: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.274062 controller.go:57: inside CS: 1 (50 msecs)
2020/03/11 16:13:55.324931 controller.go:47: left CS: 1 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:47: left CS: 2
2020/03/11 16:13:55.375434 controller.go:67: outside CS: 2 (100 msecs) 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

View File

@ -40,4 +40,7 @@
fatal error: all goroutines are asleep - deadlock! fatal error: all goroutines are asleep - deadlock!
goroutine 1 [chan receive]: 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.