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

IPC 的 mb 和 mq 无法确保 FIFO #4940

Open
Moral-Hao opened this issue Aug 13, 2021 · 2 comments
Open

IPC 的 mb 和 mq 无法确保 FIFO #4940

Moral-Hao opened this issue Aug 13, 2021 · 2 comments
Labels
bug This PR/issue is a bug in the current code.

Comments

@Moral-Hao
Copy link
Contributor

IPC中的 mb 和 mq,在缓冲区已满或者为空时,会把线程 A 挂在等待队列上。
当其他线程 B 读取数据或者发送数据后,会把之前的等待线程 A 唤醒,待线程 A 被调度后再处理数据。
若线程 A 被调度前,有高优先级的线程 C 先被调度,可能导致线程 A 处理数据失败,从而再次进入等待队列。
若 mb 和 mq 是 FIFO 类型,会导致先进入 FIFO 队列的线程 A 晚获取数据;晚进入 FIFO 队列的线程 C 反而先获取到数据。

类似于优先级翻转,这里可能发生 FIFO 翻转。

@BernardXiong
Copy link
Member

是的,此处没有做锁定,而semaphore相当于做了锁定。后面可以看看怎么来fix下

@BernardXiong BernardXiong added the bug This PR/issue is a bug in the current code. label Aug 13, 2021
@dongwencai
Copy link

uclinux里面也存在这样的问题,但是它的做法并没有把thread从mutex的suspend队列移除,只是wakeup线程,线程可以被调度,当线程获取锁的时候,才会从mutex的suspend队列将自己移除!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This PR/issue is a bug in the current code.
Projects
None yet
Development

No branches or pull requests

3 participants