user270398
user270398

Reputation: 451

deadlock in a single process -?

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

Upvotes: 4

Views: 2650

Answers (2)

Souhaib
Souhaib

Reputation: 119

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.

Upvotes: 2

justin
justin

Reputation: 104708

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.

Upvotes: 2

Related Questions