Skip to content

Thread stats API #6795

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 4 commits into from
May 15, 2018
Merged

Thread stats API #6795

merged 4 commits into from
May 15, 2018

Conversation

deepikabhavnani
Copy link

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

@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);
Copy link
Contributor

@SenRamakri SenRamakri May 3, 2018

Choose a reason for hiding this comment

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

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

Copy link
Author

Choose a reason for hiding this comment

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

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;
Copy link
Contributor

Choose a reason for hiding this comment

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

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Author

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

0xc0170
0xc0170 previously approved these changes May 4, 2018
SenRamakri
SenRamakri previously approved these changes May 8, 2018
@cmonr
Copy link
Contributor

cmonr commented May 8, 2018

/morph build

@mbed-ci
Copy link

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
Copy link

mbed-ci commented May 8, 2018

@mbed-ci
Copy link

mbed-ci commented May 9, 2018

Build : SUCCESS

Build number : 1965
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
Copy link

mbed-ci commented May 9, 2018

@cmonr
Copy link
Contributor

cmonr commented May 9, 2018

/morph test

@deepikabhavnani
Copy link
Author

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

@mbed-ci
Copy link

mbed-ci commented May 9, 2018

deepikabhavnani added 4 commits May 11, 2018 10:05
API to get all system threads information and states.
1. Removed prefix thread_ from all elements of mbed_stats_thread_t
2. #if conditions aligned to rest of the file
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
Copy link
Author

Rebased to resolve conflict

@deepikabhavnani
Copy link
Author

@SenRamakri @0xc0170 - Please review

@0xc0170
Copy link
Contributor

0xc0170 commented May 14, 2018

/morph build

@mbed-ci
Copy link

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
Copy link
Author

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

@studavekar
Copy link
Contributor

re-triggering

/morph build

@mbed-ci
Copy link

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
Copy link

mbed-ci commented May 15, 2018

@mbed-ci
Copy link

mbed-ci commented May 15, 2018

@cmonr cmonr merged commit 46c1e94 into ARMmbed:master May 15, 2018
@deepikabhavnani deepikabhavnani deleted the thread_stats branch May 15, 2018 15:08
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.

6 participants