ru
Feedback

Не попадитесь на канал ботавода! Telemetrio находит и помечает такие каналы 👉 Хотите видеть метку — оформите подписку

JusticeTech System 〽️

JusticeTech System 〽️

Открыть в Telegram

Learn to learn before you teach

Больше
Страна не указанаКатегория не указана
233
Подписчики
-124 часа
-17 дней
-230 дней
Архив постов
If someone asks you henceforth "What is a race condition?" A strong beginner answer is: A race condition is a programming problem that occurs when multiple processes, threads, or requests access a shared resource at the same time, and the final result depends on the order or timing of those operations. And always remember the formula: Multiple actors + Shared resource + Simultaneous access + Poor synchronization = Race condition
19 авг., 07:18

Where Do Race Conditions Happen? They're especially common when dealing with: Threads: Multiple threads can execute at overlapping times. Processes: Multiple processes can access shared resources. Databases: Multiple users can modify the same records. Servers: Thousands of users can send requests simultaneously. Distributed systems: Different computers can perform operations at the same time. Files: Two programs may attempt to modify the same file. Shared memory: Multiple workers can read/write the same memory.
19 авг., 07:15

That was what I was explaining herehttps://t.me/justicetechsystem/2163 Go through all the mechanisms and you'd understand better
19 авг., 07:12

Programmatically can do something like this below For example, conceptually: lock.acquire() balance = balance - 7000 lock.release() The lock basically says "I'm using this shared resource. Everyone else, wait."
19 авг., 07:11

The basic idea is: Don't allow two operations to modify the shared resource at the dangerous moment. But how?
19 авг., 07:08

Now How Do Programmers Prevent This?
19 авг., 07:07

This can actually happen in different places like online stores, ticket booking etc So it is never something you can just ignore
19 авг., 07:07

This of this way Ahmed and Daniel are editing the same notebook. The notebook says: Score = 10 but Ahamed changes it to "Score = 20" Meanwhile Daniel had already copied the old value which is "Score = 10" Then Daniel writes: Score = 15 Which now made Ahmed update effectively disappeared.
19 авг., 07:05

Lost Update is a common form of race condition where a program A changes the value but Program B later writes its own version of the value, effectively overwriting A's change.
19 авг., 07:01

Last point Lost Update in race condition
19 авг., 07:00

I will touch one more point and show you how to prevent this as programmer or developer depending on the field you fall into and i am done on this topic
19 авг., 06:59

So base on the program this can happen: Program A: Read ₦10,000 Program B: Read ₦10,000 Program A: Calculate ₦3,000 Program B: Calculate ₦3,000 Program A: Write ₦3,000 Program B: Write ₦3,000 Final balance: ₦3,000 But two withdrawals happened. That's wrong.
19 авг., 06:56

The above operation looks like one operation, but internally it can be thought of as: 1. Read balance 2. Calculate balance - 7000 3. Write the new balance
19 авг., 06:54

Now imagine two programs are running this at the same time, let's call them: Program A Program B Both want to withdraw ₦7,000. The operation will be like this balance = balance - 7000
19 авг., 06:53

Now Let's See Programming Imagine this Python program: balance = 10000 balance = balance - 7000 That's simple right? Follow me
19 авг., 06:50

I am going to dive deep now with programming so follow me gently
19 авг., 06:47

Now let's continue from here https://t.me/justicetechsystem/2163
19 авг., 06:44

1. Locks A lock is basically a mechanism that says "Someone is currently using this resource. Please wait." 2. Mutex A mutex is a specific type of locking mechanism. Mutex = Mutual Exclusion Don't let the name scare you. It basically means "Only ONE participant can enter this protected area at a time." 3. Semaphores A semaphore is different. A semaphore can allow more than one participant into a resource. 4. Synchronization Synchronization is the big umbrella concept. It means coordinating multiple things so they work together correctly. NB: Locks can provide synchronization. Mutexes can provide synchronization. Semaphores can provide synchronization. Barriers, condition variables, message queues, etc. can also help with synchronization. Synchronization doesn't necessarily mean "Only one thing can run." It means that "Make sure multiple things interact in the correct way." That's a very important distinction. 5. Atomic Operations This one is particularly important. Atomic basically means "It happens as one indivisible operation from the perspective of other threads."
19 авг., 06:43

Imagine a school has one computer that 10 students want to use now if everyone tries to use it simultaneously it will lead to chaos So we need rules for who can access what, when, and how. That's where locks, mutexes, semaphores, synchronization, and atomic operations come in.
19 авг., 06:20

Programming has similar mechanisms. They're called things like: Locks Mutexes Semaphores Synchronization Atomic operations I will not want to touch any of these but let me try
19 авг., 06:15