Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #2566

Re: < if but for and >

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.programming.threads
Subject Re: < if but for and >
Date 2014-07-28 16:28 +0000
Organization Aioe.org NNTP Server
Message-ID <20140728091410.821@kylheku.com> (permalink)
References <8d3bd44c-9e1a-4adf-9bee-b1df348d6910@googlegroups.com>

Show all headers | View raw


On 2014-07-28, philosofer <bertani.mauro.user@gmail.com> wrote:
> I reach a deadlock and I want to know if the condition is right.
> I set i != 0 and i == 0.
> Can some IT philosofer help me?

No; a deadlock is not defined as a logical contradiction or impossible
situation.

In a deadlock situation, there is no disagreement about the value of
any variable.

Loosely speaking, it is a situation in which one or more tasks in a system are
suspended, waiting for a situation which never arrives, because it is
impossible.

For instance i != 0, and a task is be waiting for i == 0.  But since i is
shared, setting i = 0 requires a mutex (setting i = 0 without a mutex would be
a bug), and it so happens that the waiting task is holding that mutex.
It won't unlock the mutex because it is waiting, and no other task will set
i = 0 because any task which tries will end up trapped, waiting for the mutex
(thereby ensnared in the deadlock).

In ordinary programming languages, variables can only have one stored value;
they hold whatever was most recently stored in them. Some integer i cannot
be simultaneously zero and nonzero. However, languages can have ambiguous
semantics, so that when we look at a program, we cannot predict whether i
will end up with the value 0 or nonzero.

In concurrent programming, a race condition can have such a consequence: the
final value of some variable depends on the execution order. Race conditions
are connected to deadlocks. Sometimes deadlocks are not easily reproduced,
because whether or not they occur hinges on a race condition. If deadlocks
always reproduced, they would be always found by developers rather than by
customers, as is often the case.

Languages can also incorporate logic reasoning via some kind of "logic
programming system". In a logic programming system, there can be a situation
where the system deduces that some variable i must be simultaneously zero and
nonzero.  At that point, the logic system would declare failure: the
propositions being considered lead to contradiction and so are false, as a
whole. (And perhaps that means that something else is true: like in a Reductio
ad Absurdum proof.) This kind of variable is not an ordinary variable
of a Von Neumann style programming language (a simple, named memory location
where a value can be stored).

Back to comp.programming.threads | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

< if but for and > philosofer <bertani.mauro.user@gmail.com> - 2014-07-28 07:22 -0700
  Re: < if but for and > Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-07-28 16:07 +0100
  Re: < if but for and > Kaz Kylheku <kaz@kylheku.com> - 2014-07-28 16:28 +0000

csiph-web