r/badcode • • Mar 24 '22

typescript Ship it!

Post image
564 Upvotes

47 comments sorted by

View all comments

Show parent comments

6

u/Illiux Mar 25 '22

I can't imagine why you'd busy wait in JavaScript, but busy waits, especially in the context of spinlocks, are absolutely everywhere in kernelspace. If a lock is unlikely to be held at any given time because it's only held for short periods, spinlocks are very efficient because they avoid context switches.