Synchronization Primitives: Difference between revisions
Jump to navigation
Jump to search
m
no edit summary
[unchecked revision] | [unchecked revision] |
(Removed dead links and added code example with GCC atomic builtins) |
mNo edit summary |
||
Line 49:
== Spinlocks ==
[[Spinlock|Spinlocks]] try to address the same problem of [[Mutual Exclusion]], but without relying on a scheduler infrastructure to make the process sleep if the resource is busy. Instead, a spinlock will keep checking the value until it has changed and usually relies on some atomic <tt>test_and_set</tt> instruction on the CPU to perform its task (See [http://developer.intel.com/design/pentium4/manuals/index_new.htm Intel Manuals] to see how <tt>xchg</tt> can be used to mimic <tt>test_and_set</tt> virtual operation).
While poorly used spinlocks will lead to severe performance penalty in single-cpu systems, wise use on multi-cpu may achieve higher throughput.
|