added code for spin-lock and perterson algorithm