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

MM_FillMem doesn't call MM_SegmentBreak like read from or write to file #21

Closed
3 tasks done
skliper opened this issue May 10, 2022 · 0 comments · Fixed by #53
Closed
3 tasks done

MM_FillMem doesn't call MM_SegmentBreak like read from or write to file #21

skliper opened this issue May 10, 2022 · 0 comments · Fixed by #53

Comments

@skliper
Copy link
Contributor

skliper commented May 10, 2022

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I reviewed the README file to see if the feature is in the major future work.
  • I performed a cursory search to see if the feature request is relevant, not redundant, nor in conflict with other tickets.

Is your feature request related to a problem? Please describe.
MM_FillMem writes memory in a tight loop here with no MM_SegmentBreak:

MM/fsw/src/mm_load.c

Lines 825 to 839 in 90cbd8d

/* Fill memory one segment at a time */
while (BytesRemaining != 0)
{
/* Last fill segment may be partial size */
if (BytesRemaining < MM_MAX_FILL_DATA_SEG)
{
SegmentSize = BytesRemaining;
}
memcpy(TargetPointer, FillBuffer, SegmentSize);
TargetPointer += SegmentSize;
BytesProcessed += SegmentSize;
BytesRemaining -= SegmentSize;
}

Both MM_LoadMemFromFile and MM_DumpMemToFile do have a MM_SegmentBreak (example):

MM/fsw/src/mm_load.c

Lines 576 to 604 in 90cbd8d

while (BytesRemaining != 0)
{
if (BytesRemaining < MM_MAX_LOAD_DATA_SEG)
{
SegmentSize = BytesRemaining;
}
if ((ReadLength = OS_read(FileHandle, ioBuffer, SegmentSize)) == SegmentSize)
{
memcpy(TargetPointer, ioBuffer, SegmentSize);
BytesRemaining -= SegmentSize;
BytesProcessed += SegmentSize;
TargetPointer += SegmentSize;
/* Prevent CPU hogging between load segments */
if (BytesRemaining != 0)
{
MM_SegmentBreak();
}
}
else
{
CFE_EVS_SendEvent(MM_OS_READ_ERR_EID, CFE_EVS_EventType_ERROR,
"OS_read error received: RC = 0x%08X Expected = %d File = '%s'", (unsigned int)ReadLength,
(int)SegmentSize, FileName);
BytesRemaining = 0;
}
}

MM_FillMem is likely quicker, but should still support a break

Describe the solution you'd like
Add MM_SegmentBreak

Describe alternatives you've considered
Could leave as is, but large fill command processing could hog the CPU

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

thnkslprpt added a commit to thnkslprpt/MM that referenced this issue Oct 23, 2022
thnkslprpt added a commit to thnkslprpt/MM that referenced this issue Mar 13, 2023
thnkslprpt added a commit to thnkslprpt/MM that referenced this issue Mar 13, 2023
dzbaker added a commit that referenced this issue May 25, 2023
…MM_FillMem

Fix #21, Add MM_SegmentBreak() to MM_FillMem()
@chillfig chillfig added this to the Equuleus milestone Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants