Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
common code by adding lock functions.
Approved by: benno