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

Thread stats API #6795

Merged
merged 4 commits into from May 15, 2018

Conversation

Projects
None yet
6 participants
@deepikabhavnani
Contributor

deepikabhavnani commented May 2, 2018

Description

Addition of API to get information of all active threads in Mbed OS.

Pull request type

[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change

CC @SenRamakri

Dependent on #6784

t2.terminate();
count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
TEST_ASSERT_EQUAL(3, count);

This comment has been minimized.

@SenRamakri

SenRamakri May 3, 2018

Contributor

@deepikabhavnani - You may want to check for the difference in the number of threads and not the absolute count. Because if we start running more threads as part of test infrastructure or for any other reason this test may break.

#warning Stack statistics are currently not supported without the rtos.
size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count)
{
MBED_ASSERT(stats != NULL);

This comment has been minimized.

@SenRamakri

SenRamakri May 3, 2018

Contributor

Should we also assert for if count == 0, for debug builds?

This comment has been minimized.

@deepikabhavnani

deepikabhavnani May 3, 2018

Contributor

In case of count 0, we will not fill up anything. But in case of NULL pointer, next operation in the code is memset which should not be performed on NULL pointer.

uint32_t thread_stack_size; /**< Thread Stack Size */
uint32_t thread_stack_space; /**< Thread remaining stack size */
const char *thread_name; /**< Thread Object name */
} mbed_stats_thread_t;

This comment has been minimized.

@0xc0170

0xc0170 May 3, 2018

Member

Do we need to repeat thread_ prefix ?

mbed_stats_thread_t says this contains tread stats. all members are related to the thread (if not they would be a separate object?). Thus would be thread_stats.id/state/priority oppose to thread_stats.thread_id ?

* @param stats A pointer to an array of mbed_stats_thread_t structures to fill
* @param count The number of mbed_stats_thread_t structures in the provided array
* @return The number of mbed_stats_thread_t structures that have been filled,
* this is equal to the number of stacks on the system.

This comment has been minimized.

@0xc0170

0xc0170 May 3, 2018

Member

this is equal to the number of stacks on the system - I do not understand stacks in this context? how many stacks we have? not threads here?

@deepikabhavnani deepikabhavnani requested a review from 0xc0170 May 3, 2018

@0xc0170 0xc0170 added needs: work and removed needs: review labels May 3, 2018

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented May 3, 2018

@0xc0170 @SenRamakri - Pushed commits addressing review comments.

@cmonr

This comment has been minimized.

Contributor

cmonr commented May 8, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented May 8, 2018

Build : SUCCESS

Build number : 1947
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6795/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@cmonr

This comment has been minimized.

Contributor

cmonr commented May 9, 2018

/morph test

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented May 9, 2018

@cmonr - As per the build log, MBED_ALL_STATS_ENABLED was not enabled. Can kill test.

@deepikabhavnani deepikabhavnani force-pushed the deepikabhavnani:thread_stats branch from 27ca65c to c651d82 May 9, 2018

@mbed-ci

This comment has been minimized.

deepikabhavnani added some commits May 1, 2018

Thread statistics addition.
API to get all system threads information and states.
Cleaup and review comments addressed
1. Removed prefix thread_ from all elements of mbed_stats_thread_t
2. #if conditions aligned to rest of the file
Cleanup
1. Enable watermark to get stack space information
2. Restructured code
3. Throw error if MBED_THREAD_STATS_ENABLED is not set
4. Astyle changes

@deepikabhavnani deepikabhavnani force-pushed the deepikabhavnani:thread_stats branch from c651d82 to 97c8818 May 11, 2018

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented May 11, 2018

Rebased to resolve conflict

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented May 11, 2018

@SenRamakri @0xc0170 - Please review

@0xc0170

This comment has been minimized.

Member

0xc0170 commented May 14, 2018

/morph build

@0xc0170 0xc0170 added the needs: CI label May 14, 2018

@mbed-ci

This comment has been minimized.

mbed-ci commented May 14, 2018

Build : SUCCESS

Build number : 1997
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6795/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@deepikabhavnani

This comment has been minimized.

Contributor

deepikabhavnani commented May 14, 2018

@0xc0170 - Command used in build does not contain ALL flags enabled. Will have to re-run once @studavekar does that change.

@studavekar

This comment has been minimized.

Collaborator

studavekar commented May 14, 2018

re-triggering

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented May 14, 2018

Build : SUCCESS

Build number : 2005
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6795/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@cmonr cmonr added ready for merge and removed needs: CI labels May 15, 2018

@cmonr cmonr merged commit 46c1e94 into ARMmbed:master May 15, 2018

13 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
travis-ci/astyle Passed, 845 warnings
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Passed, runtime is 10162 cycles (+480 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/littlefs Passed, code size is 9964B
Details
travis-ci/tools Local tools testing has passed
Details

@deepikabhavnani deepikabhavnani deleted the deepikabhavnani:thread_stats branch May 15, 2018

@cmonr cmonr removed the ready for merge label May 21, 2018

SeppoTakalo added a commit to SeppoTakalo/Handbook that referenced this pull request May 29, 2018

Added thread stat info
Changes as per ARMmbed/mbed-os#6795. Should wait for PR to merged to master
Target Release 5.9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment