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

When mutex already acquired by lower priority thread, the higher priority thread also get the same mutex without thread suspend #418

Open
devaraj-siva opened this issue Nov 12, 2024 · 1 comment
Labels
bug Something isn't working hardware New hardware or architecture support request

Comments

@devaraj-siva
Copy link

Description of the bug:
The mutex was acquired by lower priority thread and performing its thread activity and not yet released the mutex. When higher priority thread is trying to acquire the same mutex, still _tx_mutex_get() function call return TX_SUCCESS. So higher priority thread perform its thread activity and releasing the mutex. When mutex released from higher priority thread, _tx_mutex_put() function returned the value TX_NOT_OWNED. Because the mutex owner is lower priority thread. Due to TX_NOT_OWNED return value, our firmware is designed to generate software assertion.

Additional information:
Target - MIPS Interaptiv SMP CPU
Eclipse ThreadX version - threadx-6.4.1_rel
Compiler - GHS Multi compiler

Initially we tested our application in 50 MHz CPU clock. The application is working fine.
When we test our application in 1.1 GHz (1100 MHz) CPU clock, this issue is observed.

We debugged the issue and found the root cause.
Working scenario:
When higher priority thread try to get already acquired mutex, higher priority thread moved to suspended state and lower priority thread is continued its operation.

Non-working scenario:
When higher priority thread try to get already acquired mutex, higher priority thread is not moved to suspended state and keeps on running because of below "if" condition fail in _tx_thread_system_suspend() function.

/* Determine if preemption should take place. This is only possible if the current thread pointer is
not the same as the execute thread pointer AND the system state and preempt disable flags are clear. */
if (_tx_thread_system_state[core_index] == ((ULONG) 0))
{

The _tx_thread_system_state variable value is 1. So this condition is failed and higher priority thread is not moved to suspended state and keeps on running. Because the _tx_mutex_get() function return TX_SUCCESS after this condition failure.

We need proper working of mutex get function and higher priority thread should move to suspended state, if mutex is already acquired by other thread.

It is a showstopper issue for our project. Any solution to this problem is really helpful.

Thanks,
Devaraj Sivaprakasam.

@devaraj-siva devaraj-siva added bug Something isn't working hardware New hardware or architecture support request labels Nov 12, 2024
@fdesbiens
Copy link

Hi @devaraj-siva.

Thank you for the detailed bug report. I will check with the other committers to see if anyone can help you.

Out of curiosity, do you see the same behaviour when using the Arm GNU compiler? What about different hardware platforms?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hardware New hardware or architecture support request
Projects
None yet
Development

No branches or pull requests

2 participants