RT-Thread / RT-Thread/rt-thread
[Bug] ART-Pi Smart 平台 alarm() 定时相对现实时间不准确 | Inaccurate Timing of alarm()
Open
Nobody has claimed this yet.
Arch: ARM/AArch64
RT-Smart
- Dominant language
- C
- Stars
- 12.2k
- Forks
- 5.4k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 40
Description
RT-Thread Version
master
Hardware Type/Architectures
ART-Pi Smart Board
Develop Toolchain
GCC
Describe the bug
Compile the following code snippet and run the program in userspace:
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
int main() {
// 信号集合
sigset_t set;
int sig;
// 初始化信号集合
sigemptyset(&set);
sigaddset(&set, SIGALRM);
// 阻塞 SIGALRM 信号,确保 sigwait 可以捕获到该信号
if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
perror("sigprocmask");
exit(EXIT_FAILURE);
}
// 设置闹钟,3 秒后触发 SIGALRM 信号
alarm(3);
// 等待 SIGALRM 信号
printf("Waiting for the alarm...\n");
if (sigwait(&set, &sig) == 0) {
printf("Alarm triggered! Signal number: %d\n", sig);
} else {
perror("sigwait");
exit(EXIT_FAILURE);
}
// 收到信号后继续执行
printf("Program continues after alarm.\n");
return 0;
}
Other additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided userspace program on the ART-Pi Smart Board, then trace the alarm() and sigwait() entry points used by the platform. Compare the elapsed real time with the requested three seconds and identify the timing discrepancy; done means the alarm triggers at the expected interval.
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
- 35/100