Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spin waits, spin loop and busy spin

Are spin waits, spin loop and busy spin a different name for the same situation?

I read different threads and they all seem related to a loop that is "busy" checking for the availability of a resource.

like image 645
John Henry Avatar asked Mar 13 '16 11:03

John Henry


People also ask

What is a spin wait loop?

JEP 285: Spin-Wait Hints in Java. Spin loop performance can be improved in some processors using a special instruction inside the spin loop code. Spin loop, or busy waiting technique, is a loop where a certain condition is repeatedly checked, such as a flag.

What is busy spinning?

Busy Spinning is a wait strategy in which one thread waits for some condition to happen which is to be set by some other thread. Here the waiting thread loops continuously without releasing the CPU cycles. This leads to bad performance as the CPU cycles are wasted by a waiting thread.

What is the difference between busy waiting and spinlock?

Simply put: Busy waiting is a technique in which a process repeatedly checks to see if a condition is true (from Wikipedia). Spinlock uses the above technique for the purpose of checking if a lock is available.

What is the difference between busy waiting and blocking?

Hello, everyone, now, I know what's differences:D, busy waiting is a loop, the cpu will execute it all the time, block is a kind of kernel/OS control, it won't waste cpu resource.


1 Answers

Busy Spin

A technique which is used in a way that it loop is running until other thread have to complete his work.

Spin Wait

A spin wait that you have to wait until condition for thread is true.

Spin Loop

Spin loop is also similar to both of above busy spin and wait spin. It means that threads have to wait for other thread for completing his work.

By the way I think these terms can also use interchangeably. Precisely these are the same terms.

like image 164
Hamza Zafeer Avatar answered Oct 13 '22 10:10

Hamza Zafeer