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

[Bug] ART-Pi Smart 平台 alarm() 定时相对现实时间不准确 | Inaccurate Timing of alarm() #9264

Open
polarvid opened this issue Jul 29, 2024 · 0 comments
Labels
Arch: ARM/AArch64 BSP related with arm RT-Smart RT-Thread Smart related PR or issues

Comments

@polarvid
Copy link
Contributor

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

@polarvid polarvid added Arch: ARM/AArch64 BSP related with arm RT-Smart RT-Thread Smart related PR or issues labels Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: ARM/AArch64 BSP related with arm RT-Smart RT-Thread Smart related PR or issues
Projects
None yet
Development

No branches or pull requests

1 participant