Skip to content

Add thread terminate hook #4684

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

Merged
merged 2 commits into from
Sep 22, 2017
Merged

Conversation

deepikabhavnani
Copy link

Description

Hook was added in RTX4 code to assist test framework to log thread info on thread terminate, which was not working with RTX5.

Status

READY

Steps to test or reproduce

Execute test mbed-os-tests-mbedmicro-rtos-mbed-threads with MBED_STACK_STATS_ENABLED set to 1.

@c1728p9 @bulislaw

Copy link
Contributor

@c1728p9 c1728p9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix

Copy link
Contributor

@sg- sg- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event recorder changes seem to be an addition not needed for the fix. If we're going to use the event recorder that should come in an additional PR or commit (if an extension of how its already used).

#endif
}

void EvrRtxThreadTerminate (osThreadId_t thread_id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ on the new line for both functions as the rest of functions in this file

@c1728p9
Copy link
Contributor

c1728p9 commented Jul 2, 2017

@sg- the event recorder stuff is to keep the RTOS behavior the same. It's not an addition. The functions EvrRtxThreadExit and EvrRtxThreadTerminate in this PR override weak the weak versions in rtx_evr.c. If the event logic isn't the same in these overridden functions, then RTX 5 event reporting will no longer work correctly in Keil.

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sg-
Copy link
Contributor

sg- commented Jul 4, 2017

@sg- the event recorder stuff is to keep the RTOS behavior the same. It's not an addition. The functions EvrRtxThreadExit and EvrRtxThreadTerminate in this PR override weak the weak versions in rtx_evr.c. If the event logic isn't the same in these overridden functions, then RTX 5 event reporting will no longer work correctly in Keil.

OK thanks for the clarification. I had searched for that but failed from the trailing _ so I guess now the question is why is there a trailing _, why RTX_Config.h needed and why not copy the define over as part of the block rather than literal with no meaning?

@deepikabhavnani
Copy link
Author

@sg- : I added trailing _ to avoid re-definition and to know what was updated in RTX5 in case of future RTX changes. Do we have some standard mechanism to keep track of such changes (over-write behavior of RTX5), so that we do not miss them in future merges?

@bulislaw
Copy link
Member

bulislaw commented Jul 5, 2017

So why are we defining it if it causes redefinition? Can't we just use the RTX defined events? We have some CMSIS/RTX documentation here including changes to RTX, adding section that documents what's we overload in mbed_rtx_handlers.c is a good idea https://docs.mbed.com/docs/mbed-os-handbook/en/5.5/advanced/cmsis-rtos/

@theotherjimmy
Copy link
Contributor

@deepikabhavnani Bump. You may want to have a chat with @bulislaw offline to get clarification of what needs to be done.

@deepikabhavnani deepikabhavnani force-pushed the thread_stack_issue branch 2 times, most recently from 2c34d16 to cd65c34 Compare July 11, 2017 19:08
@bulislaw
Copy link
Member

@RobertRostohar @JonatanAntoni is there any reason why all the event ids are defined in .c file? https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/RTOS2/RTX/Source/rtx_evr.c all the functions are __WEAK as to be overloaded, but the event ids themselves need to be redefined in this case. Would you be open to a PR that moves the event IDs to .h file?

@theotherjimmy
Copy link
Contributor

Bump. @bulislaw @deepikabhavnani Any news?

@bulislaw
Copy link
Member

@JonatanAntoni can you look at the question above?

@deepikabhavnani
Copy link
Author

As per @JonatanAntoni: over writing event handlers is not correct way to fix this issue. PR is required to enhance RTX thread with an official exit hook.

@deepikabhavnani
Copy link
Author

Solution from CMSIS might be delayed till CMSIS 5.1 release.
@sg- @bulislaw Should we proceed with this temporary fix or hold it?

@theotherjimmy
Copy link
Contributor

@sg- @bulislaw @deepikabhavnani any news?

@deepikabhavnani
Copy link
Author

@bulislaw @sg- Solution from CMSIS will not be part of next CMSIS release as well (5.2.0) and might be delayed for long.

Shall we proceed with this temporary fix, else I would like to close this PR and keep issue open.

@bulislaw
Copy link
Member

What issues does it cause? If it's an actual problem I'll say lets bring it in now, if it's an improvement/good to have it'll probably be better to wait till it's fixed in RTX.

@deepikabhavnani
Copy link
Author

@bulislaw - Thread terminate hook is to record stack/heap related information during CI, we will not get details of threads which were terminated due to some issues. It won;t stall anything only will make debugging difficult in case of issues.

@theotherjimmy
Copy link
Contributor

@deepikabhavnani Could you rebase to resolve the conflicts?

@0xc0170 0xc0170 changed the title Added thread terminate hook Add thread terminate hook Sep 1, 2017
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 1, 2017

Hook was added in RTX4 code to assist test framework to log thread info on thread terminate, which was not working with RTX5.

@deepikabhavnani This info could be part of the commit msg to provide useful info why its being added.

I would like to close this PR and keep issue open.

Is there an issue for this? I don't see it referenced here anywhere.

Shall we proceed with this temporary fix, else I would like to close this PR and keep issue open.

I am fine with this as the fix to bring the old behavior back as it was useful and being used (in the tests mentioned above). Once RTX gets an update, we will replace this with a proper fix. If someone has a strong no for this, speak now.

@deepikabhavnani
Copy link
Author

Rebased to resolve conflicts and updated commit message

@deepikabhavnani
Copy link
Author

If everyone is ok with this solution shall we merge it? After CI :-)

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 14, 2017

I created ARM-software/CMSIS_5#245 to track this with the RTX team.

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 14, 2017

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1309

Test failed!

Hook was added in RTX4 code to assist test framework to log thread info on
thread terminate, which was not working with RTX5.
@deepikabhavnani
Copy link
Author

deepikabhavnani commented Sep 14, 2017

3 test were skipped for all targets, not sure why :-(

  • Testing thread priority ops
  • Testing thread states: wait message put
  • Testing thread with external stack memory -

Rebased and verified K64F on local setup

@deepikabhavnani
Copy link
Author

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1312

Test failed!

@deepikabhavnani
Copy link
Author

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1318

All builds and test passed!

@0xc0170 0xc0170 merged commit 1fed1d0 into ARMmbed:master Sep 22, 2017
@deepikabhavnani deepikabhavnani deleted the thread_stack_issue branch September 26, 2017 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants