From bf24d0aa0f3589b3a27583cf3243bd210bf58f4d Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 24 Mar 2020 15:59:30 +0100 Subject: [PATCH] + comments in log files --- EWD123/ewd123b/ewd123b.go | 3 +-- EWD123/ewd123c/ewd123c.go | 3 +-- protocol/a.txt | 2 +- protocol/b.txt | 9 +++------ protocol/c.txt | 4 +++- protocol/d.txt | 5 ++++- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/EWD123/ewd123b/ewd123b.go b/EWD123/ewd123b/ewd123b.go index 8714b07..875385b 100644 --- a/EWD123/ewd123b/ewd123b.go +++ b/EWD123/ewd123b/ewd123b.go @@ -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 diff --git a/EWD123/ewd123c/ewd123c.go b/EWD123/ewd123c/ewd123c.go index 4621eac..e98f574 100644 --- a/EWD123/ewd123c/ewd123c.go +++ b/EWD123/ewd123c/ewd123c.go @@ -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 } diff --git a/protocol/a.txt b/protocol/a.txt index 8d759e3..e636efb 100644 --- a/protocol/a.txt +++ b/protocol/a.txt @@ -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) diff --git a/protocol/b.txt b/protocol/b.txt index 099644b..030356c 100644 --- a/protocol/b.txt +++ b/protocol/b.txt @@ -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. \ No newline at end of file diff --git a/protocol/c.txt b/protocol/c.txt index d9b07cb..72dc45a 100644 --- a/protocol/c.txt +++ b/protocol/c.txt @@ -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 \ No newline at end of file diff --git a/protocol/d.txt b/protocol/d.txt index ebacf45..3cc47d7 100644 --- a/protocol/d.txt +++ b/protocol/d.txt @@ -40,4 +40,7 @@ fatal error: all goroutines are asleep - deadlock! goroutine 1 [chan receive]: -main.main() \ No newline at end of file +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. \ No newline at end of file