Concurrency control algorithms

Spinlock

In software engineering, a spinlock is a lock that causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking whether the lock is available. Since the thread remains active but is not performing a useful task, the use of such a lock is a kind of busy waiting. Once acquired, spinlocks will usually be held until they are explicitly released, although in some implementations they may be automatically released if the thread being waited on (the one that holds the lock) blocks or "goes to sleep". Because they avoid overhead from operating system process rescheduling or context switching, spinlocks are efficient if threads are likely to be blocked for only short periods. For this reason, operating-system kernels often use spinlocks. However, spinlocks become wasteful if held for longer durations, as they may prevent other threads from running and require rescheduling. The longer a thread holds a lock, the greater the risk that the thread will be interrupted by the OS scheduler while holding the lock. If this happens, other threads will be left "spinning" (repeatedly trying to acquire the lock), while the thread holding the lock is not making progress towards releasing it. The result is an indefinite postponement until the thread holding the lock can finish and release it. This is especially true on a single-processor system, where each waiting thread of the same priority is likely to waste its quantum (allocated time where a thread can run) spinning until the thread that holds the lock is finally finished. Implementing spinlocks correctly is challenging because programmers must take into account the possibility of simultaneous access to the lock, which could cause race conditions. Generally, such an implementation is possible only with special assembly-language instructions, such as atomic test-and-set operations and cannot be easily implemented in programming languages not supporting truly atomic operations. On architectures without such operations, or if high-level language implementation is required, a non-atomic locking algorithm may be used, e.g. Peterson's algorithm. However, such an implementation may require more memory than a spinlock, be slower to allow progress after unlocking, and may not be implementable in a high-level language if out-of-order execution is allowed. (Wikipedia).

Video thumbnail

What is the "spin" of a particle?

“Spin” is one of the core building blocks of quantum reality, but it is a subtle concept to grasp. Here’s Brian Greene with one way to think about it. Subscribe to our YouTube Channel for all the latest from World Science U. Visit our Website: http://www.worldscienceu.com/ Like us on Fac

From playlist Science Unplugged: Quantum Mechanics

Video thumbnail

ADULT SPINNER TURBINE TEST Large Scale High RPM helicopter engine part for steam turbine

ADULT SPINNER This is a turbine conversion from a helicopter engine works project. Compressor shaft. Note: I am behind polycarbonate material. http://www.greenpowerscience.com/ Never free spin anything without proper safety protection. Fingers, eyes and other things can be lost.

From playlist DIY ALTERNATOR WIND TURBINE

Video thumbnail

What is Spin?

Spin in quantum mechanics is an incredibly interesting property. However, it can be very difficult to understand what exactly it is. In this video, we dispel some misconceptions about spin as well as answer some of the more frequently asked questions about spin. #physics #quantum

From playlist Quantum Mechanics

Video thumbnail

Spin Art... centripetal force..."centrifugal" force // Homemade Science with Bruce Yeany

Spin art has been a popular device in the arts and science over the years. It is rather simple, spin a piece of paper at high speeds, splash some paints on it and then stop it and admire the results. It can be a nice piece to start a discussion on the application of centripetal forces,

From playlist Videos in the introduction

Video thumbnail

Spinlaunch Throw Rockets into Space (with something which looks like Nikola Tesla turbine)!!!

The concept behind that system is simple. Essentially, SpinLaunch wants to get to orbit by using a large, vacuum-sealed chamber and a hypersonic tether to spin a spacecraft at a high enough velocity up to 5000 miles per hour to escape the atmosphere. That means no rocket, no rocket engines

From playlist SPACE

Video thumbnail

Spinning ring puts surprising twist on familiar physics

Differences in drag cause the ring to switch directions as it wobbles around. Read more http://scim.ag/1FJbRe3

From playlist Materials and technology

Video thumbnail

Physics, Torque (1 of 13) An Explanation

Explains what torque is, the definition, how it is described and the metric units. Also presented are two examples of how to calculate the torque produced by a force. Torque is a turning force. It is a measure of how much force acting on an object that causes the object to rotate. The ob

From playlist Mechanics

Video thumbnail

Time Warp - Ink Spinner

Watch Time Warp Wednesdays at 8 pm ET. http://dsc.discovery.com/videos/time-warp/ Watch the gracefulness of paint on an ink spinner in slow motion.

From playlist Time Warp

Video thumbnail

Chem 203. Organic Spectroscopy. Lecture 23. Using TOCSY to Elucidate Spin Systems. ROESY

UCI Chem 203 Organic Spectroscopy (Fall 2011) Lec 23. Organic Spectroscopy -- Using TOCSY to Elucidate Spin Systems. ROESY. View the complete course: http://ocw.uci.edu/courses/chem_203_organic_spectroscopy.html Instructor: James Nowick, Ph.D. License: Creative Commons BY-NC-SA Terms of U

From playlist Chem 203: Organic Spectroscopy

Video thumbnail

What is general relativity?

Subscribe to our YouTube Channel for all the latest from World Science U. Visit our Website: http://www.worldscienceu.com/ Like us on Facebook: https://www.facebook.com/worldscienceu Follow us on Twitter: https://twitter.com/worldscienceu

From playlist Science Unplugged: General Relativity

Video thumbnail

Writing an OS in Rust - Part 10 - Heap Allocation

This is my version of Philipp Oppermann's "BlogOS". It's a baremetal operating system that can boot off of a USB stick on any BIOS-compatible machine, which is pretty amazing. I'm going to be following the whole blog, one video at a time, and running the OS using QEMU instead of booting a

From playlist Rust OS

Video thumbnail

#381 How to work with a Real Time Operating System and is it any good? (FreeRTOS, ESP32)

Using a real operating system to simplify programming with the Arduino IDE. Is this possible and how? Let’s have a closer look! Operating systems were invented to simplify our lives. But, because they need a lot of resources, they only run on reasonable computers like the Raspberry Pi or a

From playlist ESP32

Video thumbnail

Crust of Rust: Atomics and Memory Ordering

In this episode of Crust of Rust, we go over Rust's atomic types, including the mysterious Ordering enum. In particular, we explore the std::sync::atomic module, and look at how its components can be used to implement concurrency primitives like mutexes. We also investigate some of the got

From playlist Crust of Rust

Video thumbnail

Kernel Recipes 2019 - BPF at Facebook

This talk will provide several examples of how Facebook engineers use BPF to scale the networking, prevent denial of service, secure containers, analyze performance. It’s suitable for BPF newbies and experts. Alexei Starovoitov

From playlist Kernel Recipes 2019

Video thumbnail

Kernel Recipes 2017 - Refactoring the Linux Kernel - Thomas Gleixner

The effort to merge the real-time preemption patch into the mainline kernel requires to refactor existing infrastructure in the kernel. Such refactoring work is intrusive and potentially disruptive. This talk will take a close look at recent refactoring work and explain the scope, the be

From playlist Kernel Recipes 2017

Video thumbnail

Chem 203. Organic Spectroscopy. Lecture 27. Using HMQC-TOCSY or HSQC-TOCSY to Deal with Overlap

UCI Chem 203 Organic Spectroscopy (Fall 2011) Lec 27. Organic Spectroscopy --Using HMQC-TOCSY or HSQC-TOCSY to Deal with Overlap View the complete course: http://ocw.uci.edu/courses/chem_203_organic_spectroscopy.html Instructor: James Nowick, Ph.D. License: Creative Commons BY-NC-SA Terms

From playlist Chem 203: Organic Spectroscopy

Video thumbnail

Kernel Recipes 2018 - Evolution and use of relaxed concurrency primitives - Will Deacon

Over the past few years, the kernel has grown a modern, sophisticated memory model which is exposed directly to the developer and provides portable concurrency primitives across the 20+ architectures supported by mainline. These low-level primitives have been used to construct high-perfor

From playlist Kernel Recipes 2018

Video thumbnail

How did the concept of particles having "spin" arise from experimental studies?

Subscribe to our YouTube Channel for all the latest from World Science U. Visit our Website: http://www.worldscienceu.com/ Like us on Facebook: https://www.facebook.com/worldscienceu Follow us on Twitter: https://twitter.com/worldscienceu

From playlist Science Unplugged: Quantum Mechanics

Video thumbnail

Kernel Recipes 2022 - Looking at yourself: Linux Introspection tales

Introspection information, used originally by debuggers, has come a long way into playing a greater role in the functioning of Linux. Now its used by tracers, profilers, and then by eBPF, in libbpf, in the verifier and other parts of the kernel, being always available and fast to access.

From playlist Kernel Recipes 2022

Related pages

Ticket lock | Scheduling (computing) | Peterson's algorithm | Test-and-set | Busy waiting | Lock (computer science) | Transactional Synchronization Extensions | Deadlock | Cyrix | Mutual exclusion | Exponential backoff | Race condition | Transactional memory | Seqlock | FIFO (computing and electronics)