Added comments to make parity function easier to understand.
Updated handling of read lock and write unlock commands to be more accurate.
However, atomic operation is still not guaranteed.