There are a few in-progress books I'm writing based on the past couple of series. Hopefully I can find the time to finish them in the next few months! Cheers, --Nick
@mlecz
Жыл бұрын
Honestly, his films are much more interesting than the book.
@mariyanmomchilov9384
Жыл бұрын
In 0_reorder.cpp should we have a check if (x == 1 && y = 1) and then proceed with the order check? Is it hypothetically possible the main thread to execute multiple iterations with letting thread1 and thread2 to acquire the semaphore?
@CoffeeBeforeArch
Жыл бұрын
No, I can't think of a reason why we would need that check. The two calls to release from the main thread tell each of the spawned threads to do one iteration of the while loop in the reorder function. At the end of that loop, they (the spawned threads in the reorder function) have a call to release to say they have completed a single iteration. During that time, both main thread is just waiting for the two calls to release (from each spawned thread) with its two calls to acquire. So the only way for the main thread to continue is for the spawned threads to complete one iteration of the while loop. The spawned threads will also only continue to their next iteration when the main thread does another iteration of its for loop, and triggers the spawned threads to proceed with another call to release on each semaphore.
@mariyanmomchilov9384
Жыл бұрын
@@CoffeeBeforeArch Thanks for the explanation. My question comes from the fact If the processor has only one core (of course not relevant in practice) is it possible thread 1 and thread 2 to starve? Im not sure if semaphores provide fairness. if that's not provided In case of multiple cores it is possible one of the threads to starve.
@CoffeeBeforeArch
Жыл бұрын
@@mariyanmomchilov9384 it really comes doesn't to the specific implementation details. So long as the threads can be interrupted and put to sleep, the waiting thread can be paused, and a thread with work can be resumed.
@takiemtam1
Жыл бұрын
Can you pls create some graphic model for visualization, I think it's better to understand
@mariyanmomchilov9384
Жыл бұрын
Thanks for the great video! Does std::atomic use fences under the hood for each type of processor?
Пікірлер: 10