In this article, I talk about thread-safety and a specific but common case of it. I didn’t cover the thread-safety concepts in detail and I briefly explain the related ones only. This article considers that the reader has some knowledge about thread-safety, operating system concepts and computer architecture.
Protecting the data from race condition is a complex job and there are various solutions. Generic thread-safety mechanisms (mutex, etc) work great but their performance impact on the system may be huge. In some cases, it is possible to develop lock-free algorithms or disable the locks, temporarily. Developing a customized thread-safety solution according to your needs, doesn’t only protect your data from race condition, it saves your system resources, speeding up your operations as well.
We will design a simple firewall that checks if the IP address of the client is allowed to show an example. Multiple threads will be executed and they will use a shared whitelist for this operation. We will keep the whitelist in a database and we won’t query it for every request. It is quite expensive. So, we will cache the data and update it (timely or depending on a trigger) ; a trigger would be better.
Pathfinding algorithms are one of the most important subjects of computer science. They are used in fields such as video games, geography information systems, and networking. They depend on Graph Theory.
Pathfinding algorithms are used for different purposes like finding the shortest route to reduce fuel consumption, calculating the most suitable way for an AI character that belongs to a video game, redirecting network packages to the best way possible, etc.
These algorithms may have so many different variations and they could get so many different parameters according to the circumstances. The shortest way might not be the best way. If a pathfinding algorithm is calculating a path, it should also consider traffic, road work, roads in poor condition, hills, tolls, bridges, etc. Otherwise, it could cause more harm than good. So, finding the best way might be more important than finding the shortest way.
These representations are made with graphs. For example, A, B, C are cities and they are called "nodes". Roads are edges. This graph is an undirected graph. Because the edges are both inbound and outbound. It is also cyclic. Because the graph is closed.
Even though modeling reality is mostly difficult in life, approximation is possible via predictions which is updated by observations. Initial predictions which do not depend on well analogical inferences, may cause high deviations. But, these predictions may be better if their effects are measurable, follow certain patterns and the results are evaluated, properly. Deviation from reality, may become lower with the inclusion of experience.
Classical physics which looks deterministic, deviates from reality because of factors which are not considered in equation. So, predictions should be revised to avoid from increasing deviation. Equations are just models and they are not equivalent to reality. Results differ slightly from actual. But, small errors increase with the time and deviation increases.
Information
I completely translated my website into the English language. It is time for a new start.