Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有关阻塞/同步一节中的说法不准确 #180

Open
jackyfkc opened this issue Jun 16, 2022 · 0 comments
Open

有关阻塞/同步一节中的说法不准确 #180

jackyfkc opened this issue Jun 16, 2022 · 0 comments

Comments

@jackyfkc
Copy link

阻塞、非阻塞 一节中,关于阻塞/同步的说法个人认为是不准确的

阻塞 指的是一个函数或者操作本身的特性,比如我们会说 read() 系统调用, BlockingQueue.put() 是阻塞(block) 的,是因为这类函数要在返回之前等某个事情发生或者完成;至于跟调用者, 被调用者有关还是无关,这之间没什么关联

可以参看 Tornado Asynchronous and non-Blocking I/O 一节
A function blocks when it waits for something to happen before returning. A function may block for many reasons: network I/O, disk I/O, mutexes, etc. In fact, every function blocks, at least a little bit, while it is running and using the CPU (for an extreme example that demonstrates why CPU blocking must be taken as seriously as other kinds of blocking, consider password hashing functions like bcrypt, which by design use hundreds of milliseconds of CPU time, far more than a typical network or disk access).

同步 是指调用方要等被调用方完成,不仅仅是描述被调用方的

最后同步和阻塞是二个无关的概念,二者是正交的

@jackyfkc jackyfkc changed the title 关于 阻塞/同步的说法 有关阻塞/同步一节中的说法不准确 Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant