What does lock keyword in open function?

Thank you for your help. I will try to implement it.

I was also doing some reading. Will it be good if I try to implement lock by ccall to flock or fcntl?