🎯 Sync smart & scheduler codes by polarvid · Pull Request #8537 · RT-Thread/rt-thread

Guozhanxin

Guozhanxin

@BernardXiong BernardXiong changed the title Sync smart & scheduler codes 🎯 Sync smart & scheduler codes

Feb 19, 2024

geniusgogo

geniusgogo

@mysterywolf mysterywolf linked an issue

Feb 20, 2024

that may be closed by this pull request

mysterywolf

mysterywolf

BernardXiong

BernardXiong

BernardXiong

BernardXiong

BernardXiong

mysterywolf

Add Support for ~FUTEX_PRIVATE, and futex requeue and futex pi feature.

Co-authored-by: xqyjlj <xqyjlj@126.com>
Signed-off-by: Shell <smokewood@qq.com>
In the previous implementation, each call will create a new timer object
for the process. But according to the manual, the itimer is a singleton
object per-process.

This un-compatible semantic will corrupt the API by a call to cancel
previous setup timer.

Signed-off-by: Shell <smokewood@qq.com>
This patch adds an abstraction layer of scheduler(rt_sched). Following
features are added:

- The scheduler class (rt_sched) is added for rtthread source and ipc
  primitives. Critical region of scheduler is also redesigned to
  simplify the synchronization and acquire better performance.
- Support nested lock/unlock detection for scheduler
- Suspended thread and completed status tracking of rt_completion is
  modified for smaller footprint and easier locking.
- Add suspend list - A basic building block for IPC primitives which
  interacts with scheduler directly. Its API is similar to a FIFO list.
  This new object simplify the synchronization between IPC primitives
  and asynchronization event like timeout, signals. And it fixed the
  data racing commonly found on IPC objects currently.
- add RT_TIMER_FLAG_THREAD_TIMER as new type of rt_timer for rt_thread,
  so the timer is notified to do the necessary co-op with scheduler, as
  the legacy semantics required.

Besides, following bugs are fixed:

- _scheduler_get_highest_priority_thread() may access an empty list, and
  cause the codes to corrupt.
- rt_thread_control(RT_THREAD_CTRL_CHANGE_PRIORITY) has data racing with
  scheduler codes, by the leaving of the critical region for a while
  which corrupts the data coherency of ready queue.
- data racing on rt_completion.
- in rt_timer_check(): rt_hw_cpu_id() should be called with IRQ masked.
- fixup of mutex_delete(). While mutex owner did not release the mutex
  but delete it after taken, the prio inheritance algorithm may cause
  the owner thread to lose its original priority. This patch fix this
  issue by adding a thread priority restore on rt_mutex_delete()/
  rt_mutex_detach() API.
- For qemu-vexpress-a9, fixup boot-up failure while RT_CPUS_NR is config
  as 1.

Signed-off-by: Shell <smokewood@qq.com>
Signed-off-by: Shell <smokewood@qq.com>

@polarvid

@polarvid polarvid marked this pull request as ready for review

February 23, 2024 01:32

mysterywolf

BernardXiong

geniusgogo

geniusgogo

geniusgogo

geniusgogo

geniusgogo

geniusgogo

@polarvid

@polarvid

geniusgogo