Skip to content

Conversation

@thesamprice
Copy link

Details:

  • add OS_resource_stats_t and OS_GetResourceStats for totals/used counts

  • count active objects via ID map iteration

  • add unit and coverage tests for stats and null handling

Checklist (Please check before submitting)

Describe the contribution
Adds an API to retrieve the OS usage counts.
I plan to stop and restart apps and monitor the OS resource usages to detect resource leaks.

Testing performed
Steps taken to test the contribution:
Tests added, full coverage / branch coverage.
2. Execution steps '...'

Expected behavior changes
A clear and concise description of how this contribution will change behavior and level of impact.

  • API Change: xxx (if applicable)
  • Behavior Change: xxx (if applicable)
  • Or no impact to behavior

System(s) tested on
Linux

Additional context
Add any other context about the contribution here.

Third party code
This code was developed with the codex ai

Contributor Info - All information REQUIRED for consideration of pull request
Full name and company/organization/center of all contributors ("Personal" if individual work)

  • Note CLAs apply to only software contributions.

}
}

static uint32 OS_CountActiveForObjectType(osal_objtype_t idtype)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
}
}

int32 OS_GetResourceStats(OS_resource_stats_t *stats)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
Details:

- add OS_resource_stats_t and OS_GetResourceStats for totals/used counts

- count active objects via ID map iteration

- add unit and coverage tests for stats and null handling
@thesamprice
Copy link
Author

Let me know if this is desirable and I should work it more.

@thesamprice
Copy link
Author

Feel free to close this, I am now going to use the RTEMS api for getting resources.

However you could modify this to use the rtems/vx works implementations, and fall back to this osal methods for OS systems that do not have resource snapshots.

https://docs.rtems.org/doxygen/main/group__libcsupport.html#ga89d650cbacc4217c00298014c7bfb723

@joelsherrill
Copy link

Feel free to close this, I am now going to use the RTEMS api for getting resources.

However you could modify this to use the rtems/vx works implementations, and fall back to this osal methods for OS systems that do not have resource snapshots.

https://docs.rtems.org/doxygen/main/group__libcsupport.html#ga89d650cbacc4217c00298014c7bfb723

In case it helps someone, that family of APIs is used in the RTEMS tests to take a resource snapshot before a series of operations and check that at the end, no resources were leaked. These could be used by user unit tests for the same purpose. I know most RTEMS applications run until the hardware is shutdown or reset but sometimes you have a more dynamic application and avoiding leaks is important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants