Question

Why might it be considered bad practice to use a spinlock to enforce mutual exclusion on...

Why might it be considered bad practice to use a spinlock to enforce mutual exclusion on a computer with one core, but be acceptable to do so on a computer with multiple cores?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In software engineering, a spinlock is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available.

for one core systems spinlock is a bad practice because

The nature of a spinlock is that it does not deschedule the process - instead it spins until the process acquires the lock which means it spins in a loop until it acquires the lock.

On a uniprocessor, it will either immediately acquire the lock or it will spin forever - if the lock is contended which means if there is a competition for lock, then there will never be an opportunity for the process which currently holds the resource to give it up. Spinlocks are only useful when another process can execute while one is spinning on the lock - which means multiprocessor systems.

so in uniprocessor systems it is not best practice because it will waste the resources and slowing down the process time which means wastes the time of the process which is running in uni core system because it spins in the loop for necessary resources to run the process.

this is the reason to say that spinlock is a bad practice in uni core system.

Add a comment
Know the answer?
Add Answer to:
Why might it be considered bad practice to use a spinlock to enforce mutual exclusion on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT