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

代码里面有个地方没看明白 #2

Open
zemora opened this issue Jan 21, 2020 · 0 comments
Open

代码里面有个地方没看明白 #2

zemora opened this issue Jan 21, 2020 · 0 comments

Comments

@zemora
Copy link

zemora commented Jan 21, 2020

您好:有个问题想请教一下,在 这个地方的 86-88 行里面,你是先释放了 freeslots 的空间使得其等于 buffer 大小,然后又 acquire 了整个 buffer 大小的 freeslots,然后才清除整个缓冲队列,最后 94 行又释放了所有的 freeslots.

这个地方我不明白的是为什么需要这个先释放后获取然后再释放这三步操作。我理解的是前面锁定了两个 clearbuffer1,2 信号量以后这整个操作就原子化了,完全可以只保留 86 行的释放,删除 88 和 94 行,或者删除 86, 88 行,在 94 行里面释放?

还望不吝指教,谢谢!

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