Error message

  • Deprecated function: Return type of DatabaseStatementBase::execute($args = [], $options = []) should either be compatible with PDOStatement::execute(?array $params = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2244 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /home2/psicolog/public_html/feliponcho/includes/database/database.inc).
  • Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in drupal_random_bytes() (line 2268 of /home2/psicolog/public_html/feliponcho/includes/bootstrap.inc).
  • Deprecated function: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated in url() (line 2349 of /home2/psicolog/public_html/feliponcho/includes/common.inc).
  • Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in url_is_external() (line 2393 of /home2/psicolog/public_html/feliponcho/includes/common.inc).
  • Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in url_is_external() (line 2395 of /home2/psicolog/public_html/feliponcho/includes/common.inc).
  • Deprecated function: ltrim(): Passing null to parameter #1 ($string) of type string is deprecated in url() (line 2311 of /home2/psicolog/public_html/feliponcho/includes/common.inc).

Deadlocks

This is the story of two greedy threads. These two greedy threads wanted to get a resource whilst they were holding another. It is well known that when a thread holds a resource, some other thread may need that resource and should wait patiently inactive until the resource is freed. That works well among normal threads, but the greedy threads in this story they want to hold two or more resources for themselves. 

Happens in this story that in at particular time, one of the greedy threads held a resource needed by another greedy thread that was already holding a resource needed by the first thread, what a mess!. Their greedness lead them to waiting forever as any of them would release their resource for letting the other complete.

This childist story is a real deal in multithreaded systems that share resources. This problem may come not only in bad designed systems but in systems with very high resource sharing. Even the better system design can´t avoid this situation as deadlocks can come not only between two threads, it can involve any number of resources and threads.

So, a deadlock can be defined as a circular dependency between tasks and resources.

There are four conditions that may cause a deadlock. The merely prescence of only one of them means deadlock may occur in the system. Theoretically, if all this conditions are avoided then we will have a deadlock free system (that, in my personal opinion, makes a very boring system and useless for the means of multithreading enlightened).

  1. Mutual exclusion

A system that have at least one resource that can be simultaneously used only by one thread or by a limited number of threads.

  1. Hold and Wait

All threads wait for more resources they need without freeing the resources they already have (remember greedy threads?).

  1. No resource preemption

When a resource is allocated by a thread, the RTOS can´t cancel this allocation. (the marine has more power than the captain)

  1. Circular wait devil

If we represent some resource sharing by threads in a graph, we may identify a circular dependency in the graph.