fabiansch / esep_sortingmachine

0 stars 1 forks source link

find solution for deadlock caused of channels #88

Closed fabiansch closed 6 years ago

fabiansch commented 6 years ago

problem 1 of the current channel implementation in branch logic_layer is that a deadlock between Timer and Controller would be possible:

Timer is sending a Signal to Controller. At that time the queue of Controller is full so that Timer's send operation is done in a blocking manner. At the same time Controller is sending a Signal to Timer, too. The queue of Timer also is full. Now Controller's send operation also is done in a blocking manner and we have a deadlock between Timer and Controller thread.

Reaching this point is possible because also other modules can send to Channel and to Timer.

problem 2 of the current channel implementation in branch logic_layer is that our programm cannot shut down if one blocked send to a channel is performed.

Ticket is DONEwhen solution is found. Implementation gets done on #89

fabiansch commented 6 years ago

work is done on branch channel.

fabiansch commented 6 years ago

problem 2 is faced with introducing member variable bool release to semaphore. release gets part of condition variable so that condition variable always returns true when release == true. The destoy method of semaphore sets release to true and performs a notify_all() afterwards so that all blocked callers get realeased.

fabiansch commented 6 years ago

problem 1 (deadlock) is faced with a timeout signal in combinatin with an exception. If two channels wants to send to each other a message while their queues are full, both will block as normal. After a timeout both can write on current_max_size + 1 what is no problem because the queue has dynamic size and an exception gets returned to caller so that this one can handle the situation (savestate directly or when it happens again)