Fix UB in the locking code of context switching
The spin crate considers it UB to call force_write_unlock while there is a threads trying to obtain a read lock on the same rwlock.
This also switches to the spinning_lot crate for the context rwlock as it has support for a write guard keeping a reference to the rwlock using an Arc instead of a reference.