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

Free resources in cpuinfo_deinitialize #208

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

prashanthswami
Copy link
Collaborator

Users of the library can choose to release all resources the library may have allocated as part of a previous cpuinfo_initialize call. If no resources were previously allocated, this function does nothing.

Callers cannot re-initialize after the cpuinfo_deintialize call, as the library assumes initialization is a one-time operation per-process. Further, de-initializing can invalidate pointers previously acquired from cpuinfo (e.g. structures returned from cpuinfo_get_current_processor).

As such, callers should only call cpuinfo_deinitialize when:

  1. There are no further uses of references returned from cpuinfo.
  2. There are no further calls to cpuinfo_* functions.

Fixes #150

Users of the library can choose to release all resources the library may
have allocated as part of a previous cpuinfo_initialize call. If no
resources were previously allocated, this function does nothing.

Callers cannot re-initialize after the cpuinfo_deintialize call, as the
library assumes initialization is a one-time operation per-process.
Further, de-initializing can invalidate pointers previously acquired from
cpuinfo (e.g. structures returned from cpuinfo_get_current_processor).

As such, callers should only call cpuinfo_deinitialize when:
1. There are no further uses of references returned from cpuinfo.
2. There are no further calls to cpuinfo_* functions.
@prashanthswami
Copy link
Collaborator Author

Review: @malfet

Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

Hmm, there are not test to validate that it still works, is there?

Also, I see few pthread_once calls in cpuinfo_initilize, can you please explain how those resources would be freed?

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.

Missing cpuinfo_deinitialize implementation
3 participants