[ad_1]
I learn from Apple that GCD is usually sooner than locks, because it doesn’t contain trapping the kernel to amass a mutex.
Reference right here: https://developer.apple.com/library/archive/documentation/Basic/Conceptual/ConcurrencyProgrammingGuide/ThreadMigration/ThreadMigration.html)
Queues don’t impose the identical penalties as locks. For instance, queueing a job doesn’t require trapping into the kernel to amass a mutex.
I totally perceive that that is the case for dispatch_async. However what about dispatch_sync which can block the present working thread. How is it attainable with out utilizing a lock in kernel mode? (Assuming it is not utilizing a spin lock that retains spinning CompareAndSwap or TestAndSet)
[ad_2]
