process start if read then obtain shared read lock on the original text file read the data release shared lock elsif write then obtain exclusive write lock on the temporary file write the data obtain exclusive write lock on the original file overwrite the original file with new data release lock on original file release lock on temporary file end if