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

FreeRTOS scheduler does not preempt on Linux target (IDFGH-13539) #14429

Closed
3 tasks done
snake-4 opened this issue Aug 23, 2024 · 2 comments
Closed
3 tasks done

FreeRTOS scheduler does not preempt on Linux target (IDFGH-13539) #14429

snake-4 opened this issue Aug 23, 2024 · 2 comments
Labels
Resolution: Cannot Reproduce Issue cannot be reproduced Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@snake-4
Copy link
Contributor

snake-4 commented Aug 23, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.4-dev-2004-g8e4454b285

Espressif SoC revision.

Linux

Operating System used.

Linux

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

None

Power Supply used.

USB

What is the expected behavior?

Scheduler should preempt all tasks since the option is enabled by default in ESP-IDF.

What is the actual behavior?

The scheduler doesn't seem to preempt tasks with busy loops on the Linux target. This results in most components locking up the system.

Steps to reproduce.

  • main/app_main.c
#include <freertos/FreeRTOS.h>
#include <freertos/timers.h>
#include <freertos/task.h>
#include <stdio.h>

static void timer_cb(TimerHandle_t) {
    puts("timer_cb called");
}

static void task_cb(void *) {
    for (;;) {}
}

void app_main(void) {
    xTimerStart(xTimerCreate("Timer", pdMS_TO_TICKS(500), pdTRUE, NULL, timer_cb), 0);
    vTaskDelay(pdMS_TO_TICKS(2000));

    xTaskCreate(task_cb, "Task", 1024, NULL, tskIDLE_PRIORITY, NULL);
    vTaskDelay(pdMS_TO_TICKS(2000));
}
  • main/CMakeLists.txt
idf_component_register(SRCS "app_main.c")
  • CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(firmware)

Observe how the timer stops getting called after the task is created.

Debug Logs.

No response

More Information.

My previous bug report #14395 was likely caused by this issue.

@snake-4 snake-4 added the Type: Bug bugs in IDF label Aug 23, 2024
@github-actions github-actions bot changed the title FreeRTOS scheduler does not preempt on Linux target FreeRTOS scheduler does not preempt on Linux target (IDFGH-13539) Aug 23, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 23, 2024
@louielauanu
Copy link
Collaborator

louielauanu commented Aug 28, 2024

Hi @snake-4,

I pasted your code and tried to reproduce the issue at my end using Linux target. I slightly modified the task_cb to make it print every second, and here is my output:

timer_cb called
timer_cb called
timer_cb called
timer_cb called
task executes
timer_cb called
timer_cb called
task executes
timer_cb called
timer_cb called
task executes
timer_cb called
timer_cb called
task executes
timer_cb called
timer_cb called
task executes
timer_cb called
timer_cb called
task executes

I see both task and time execute as expected. Do you mean that at your end timer output stops at some point? Can you share your log output?

Thanks,
Xiaoyu

@snake-4
Copy link
Contributor Author

snake-4 commented Aug 28, 2024

Sorry, this report might've been in error as I also noticed that it works fine. Maybe the behavior under GDB was different due to signal configuration.

@snake-4 snake-4 closed this as completed Aug 28, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable Resolution: Cannot Reproduce Issue cannot be reproduced and removed Status: Opened Issue is new Resolution: NA Issue resolution is unavailable labels Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Cannot Reproduce Issue cannot be reproduced Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants