Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Are thread holding spinlocks deletion safe?
I mean if say a thread t1 is holding a spinlock, then can an another thread t2 wanting the spinlock delete the thread t1 if say t1 is not releasing the spinlock?
Posted

After deleting thread t1, the lock will still be in a non-signalled state. If you terminate t1, then you still need to release the lock.
 
Share this answer
 
Careful with that axe, Eugene (for axe, read "terminate thread"). One of the common uses for "spin locks" (or any lock for that matter) is to ensure that an object and/or structure is in a consistent state and is modified in an "atomic operation". For example, forward / backward and head / tail links in a linked list.

So, if you decide to up and kill a thread that owns a spin lock, not only is the lock in an "indeterminate state" (chances are it's "locked") but any object / structure it was operating on is also in an indeterminate state, that is, some of the items may be updated, others may not. This means that the object may be rendered useless for future updates, it is not "consistent".

So your recovery from killing the thread might be a lot more complex that just resetting the spin lock.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900