What does a lock do on a canal?

Can you answer this question?