function OWNRESOURCES(Resource R)Acquire lock L / / a global lockif R is available thenAcquire RRelease lock Lelseif R is owned by another process P thenTerminate P, after releasing all resources owned by PAcquire RRestart PRelease lock Lend ifend ifend function