-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
select() blocks the FreeRTOS scheduler on Linux target (IDFGH-13498) #14395
Comments
I've tracked it down to this line:
MQTT task seems to call |
Here's what I've found so far: When the code is compiled for the embedded targets, lwIP's FreeRTOS port correctly uses the FreeRTOS for the timeout, so the task will sleep and the lower priority task will be ran by the scheduler. However, when the Linux's This problem will happen with every slow syscall on the Linux target. A simple solution would be to call the actual |
The select function wrapper was rewritten to be non-blocking on Linux systems, as it was stealing all the CPU time from lower priority tasks when called from a higher priority task. This is because the FreeRTOS scheduler does not know that the task thread is sleeping during the system call. This issue manifests all "slow" system calls on the Linux target, but handling the case of select fixes the problems for most ESP-IDF components. The FreeRTOS POSIX port documentation lists this as a known issue, so user code is responsible handling this case if other system calls are used, even if unknowingly. This closes espressif#14395 "select() blocks the FreeRTOS scheduler on Linux target" (IDFGH-13498).
The select function wrapper was rewritten to be non-blocking on Linux systems, as it was stealing all the CPU time from lower priority tasks when called from a higher priority task. This is because the FreeRTOS scheduler does not know that the task thread is sleeping during the system call. This issue manifests all "slow" system calls on the Linux target, but handling the case of select fixes the problems for most ESP-IDF components. The FreeRTOS POSIX port documentation lists this as a known issue, so user code is responsible handling this case if other system calls are used, even if unknowingly. This closes GH issue espressif#14395 "select() blocks the FreeRTOS scheduler on Linux target"
The select function wrapper was rewritten to be non-blocking on Linux systems, as it was stealing all the CPU time from lower priority tasks when called from a higher priority task. This is because the FreeRTOS scheduler does not know that the task thread is sleeping during the system call. This issue manifests all "slow" system calls on the Linux target, but handling the case of select fixes the problems for most ESP-IDF components. The FreeRTOS POSIX port documentation lists this as a known issue, so user code is responsible handling this case if other system calls are used, even if unknowingly. This closes GH issue espressif#14395 "select() blocks the FreeRTOS scheduler on Linux target"
The select function wrapper was rewritten to be non-blocking on Linux systems, as it was stealing all the CPU time from lower priority tasks when called from a higher priority task. This is because the FreeRTOS scheduler does not know that the task thread is sleeping during the system call. This issue manifests all "slow" system calls on the Linux target, but handling the case of select fixes the problems for most ESP-IDF components. The FreeRTOS POSIX port documentation lists this as a known issue, so user code is responsible handling this case if other system calls are used, even if unknowingly. This closes GH issue espressif#14395 "select() blocks the FreeRTOS scheduler on Linux target"
The select function wrapper was rewritten to be non-blocking on Linux systems, as it was stealing all the CPU time from lower priority tasks when called from a higher priority task. This is because the FreeRTOS scheduler does not know that the task thread is sleeping during the system call. This issue manifests all "slow" system calls on the Linux target, but handling the case of select fixes the problems for most ESP-IDF components. The FreeRTOS POSIX port documentation lists this as a known issue, so user code is responsible handling this case if other system calls are used, even if unknowingly. This closes GH issue espressif#14395 "select() blocks the FreeRTOS scheduler on Linux target"
Answers checklist.
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
What is the expected behavior?
The scheduler should continue executing other tasks as expected while the MQTT client is connected to a server.
What is the actual behavior?
The scheduler no longer switches between tasks when the MQTT client establishes a connection.
Steps to reproduce.
The above code when built for the Linux target, will block the FreeRTOS scheduler while it attempts to establish a connection and while it maintains the connection.
Debug Logs.
No response
More Information.
No response
The text was updated successfully, but these errors were encountered: