reapplied optimized arm rwsem algorithm