What does it mean for a process to block?

2019-09-10 04:04发布

问题:

In my OS class, my professor keeps using block as a verb instead of an adjective when describing multi-threading/synchronization. For example: "Thread B tries to access a resource that is currently being used by Thread A, and so Thread B blocks."

Without any prior knowledge, I would initially think that for a thread to block, it would be preventing some other thread from doing something (e.g. it holds the lock on a resource). But from the way he talks, it sounds like "Thread B blocks" actually means that Thread B is being blocked, or prevented, from accessing the resource it wants to access.

Which is correct?

回答1:

Your interpolation is correction: When it is said "Thread B blocks" it means that thread B's operation is suspended pending some condition (which may or may not be achieved, "not" being the case in a deadlock for instance).