I did something similar in the attached file and did not see any failures or deadlocks in 22K runs.
I discovered another race which does not seem to be addressed by Andreas' ENSURE-WAKEUP: when %WAIT-FOR-MUTEX succeeds in the :OK case before being interrupted, ENSURE-WAKEUP performs a recursive lock attempt.
I did something similar in the attached file and did not see any failures or deadlocks in 22K runs.
I discovered another race which does not seem to be addressed by Andreas' ENSURE-WAKEUP: when %WAIT-FOR-MUTEX succeeds in the :OK case before being interrupted, ENSURE-WAKEUP performs a recursive lock attempt.