Input/Output Learning Mode

Which of the following techniques will guarantee a lock safe from any race condition?