RT-Thread / RT-Thread/rt-thread

IPC 的 mb 和 mq 无法确保 FIFO

Open
#4,940 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

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

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the RT-Thread IPC implementations for mb and mq, then trace their full-buffer and empty-buffer wait-queue wake-up and scheduling paths. Reproduce the described priority interaction with three threads and verify whether FIFO waiters can be overtaken; done means the intended FIFO ordering is preserved and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.