4

Can the condition when single process/thread is blocked trying to acquire the same mutex be called "deadlock"?

mutex_lock(&mutex) - success
...
mutex_lock(&mutex) - blocked, mutex not released

Seems as condition of "nonshearable resource" doesn't apply: here is only single process/thread so that no case of nonshearable resource hold and wait: here is only single process so that no wait for another process to release the requested resource

justin
  • 104,054
  • 14
  • 179
  • 226
user270398
  • 451
  • 7
  • 22
  • 1
    With a [recursive mutex](http://stackoverflow.com/q/187761/60761) the problem would not occur. Without it it's just an error in the algorithm. – H H May 13 '12 at 10:13
  • Absolutely... i am just wondering about apparent formal discrepancies with Colleman's "4 neccessary conditions of deadlock": 2. Hold and Wait or Resource Holding: A process is currently holding at least one resource and requesting additional resources which are being held by other processes - no other processes in this case – user270398 May 14 '12 at 17:10
  • Your thread is requesting a resource that is already held by a thread. That it's the same thread does not matter, just peculiar. – H H May 14 '12 at 17:30

2 Answers2

2

yes, that is considered, or would potentially* result in deadlock.

the term is not bound to threads or processes - but requests.

suppose your lock (mutex) is not reentrant, and suppose your resource is locked when mutated, and that it is an error to mutate the resource from multiple sources. what happens when/if your single threaded process attempts to initiate a new mutation of the data within a mutation and the non-reentrant lock which is locked is requested to lock? deadlock

'potentially', because you have not specified exactly what type of mutex you are dealing with.

justin
  • 104,054
  • 14
  • 179
  • 226
2

No, it's not a Deadlock.

Deadlock can arise if four conditions hold simultaneously.

  • Mutual exclusion: The resources involved must be unshareable; otherwise, the processes would not be prevented from using the resource when necessary. Only one process can use the resource at any given instant of time.
  • Hold and wait or resource holding: a process is currently holding at least one resource and requesting additional resources which are being held by other processes.
  • No preemption: a resource can be released only voluntarily by the process holding it.
  • Circular wait: each process must be waiting for a resource which is being held by another process, which in turn is waiting for the first process to release the resource. In general, there is a set of waiting processes, P = {P1, P2, …, PN}, such that P1 is waiting for a resource held by P2, P2 is waiting for a resource held by P3 and so on until PN is waiting for a resource held by P1.

more...

With a single process, the Circular Wait condition can never be met, thus deadlock can never arise with a single process.

Souhaib
  • 119
  • 1
  • 6