-
Notifications
You must be signed in to change notification settings - Fork 97
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
[FEATURE] Add SoC time stamp forwarding feature in BSD semaphore design #229
Conversation
- Create a shared memory between kernel and user layer to store SoC timestamps using mmap. - The initialized shared memory is unmapped during the exit of the function. Change-Id: Ia1e0926db05520ea7bf7e12c4a801d05e54c4fa9
// Close the semaphore | ||
sem_close(instance_l.syncSem); | ||
// Unlink the semaphore | ||
sem_unlink(TIMESYNC_SYNC_BSDSEM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the semaphore cleanup outside of this function!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled semaphore clean up outside the function, instead the handling is done using goto statements inside the same function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplication: If you do sem_close() and sem_unlink() in timesynckcal_init() if createTimestampShm() fails, you can workaround code duplication!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
// Close the semaphore | ||
sem_close(instance_l.syncSem); | ||
// Unlink the semaphore and timesync shared memory | ||
sem_unlink(TIMESYNC_SYNC_BSDSEM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the semaphore cleanup outside of this function!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled semaphore clean up outside the function, instead the handling is done using goto statements inside the same function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplication: If you do sem_close() and sem_unlink() in timesynckcal_init() if createTimestampShm() fails, you can workaround code duplication!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
//Close the semaphore | ||
sem_close(instance_l.syncSem); | ||
//Unlink the semaphore and timesync shared memory | ||
sem_unlink(TIMESYNC_SYNC_BSDSEM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the semaphore cleanup outside of this function!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled semaphore clean up outside the function, instead the handling is done using goto statements inside the same function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplication: If you do sem_close() and sem_unlink() in timesynckcal_init() if createTimestampShm() fails, you can workaround code duplication!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
#if defined(CONFIG_INCLUDE_SOC_TIME_FORWARD) | ||
ret = createTimestampShm(); | ||
if (ret != kErrorOk) | ||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do semaphore cleanup here if createTimestampShm() fails!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Semaphore cleanup is already done at createTimestampShm() so it is not required to do it again here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function should only clean up those resources which are created in the same function before in case of an error during creation. Of course the clean up in case of an exit might happen in an other function. createTimestampShm() is not creating the semaphore, thus, I would prefer to clean up the semaphore in timesynckcal_init() if createTimestampShm() fails!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
ret = destroyTimestampShm(); | ||
if (ret != kErrorOk) | ||
{ | ||
DEBUG_LVL_ERROR_TRACE("%s() timesync shared memory exit failed", __func__); // TODO:Handle ret value in upper layers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop that TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user tries to re run the POWERLINK application after an unsuccessful "POWERLINK exit" he will be facing errors due to improper exit, so the previous error handling traces will support the user to debug and progress further.
Hence it is necessary to handle the return value in the upper layers as well, so the TODO is essential here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean to drop the error trace! I completely agree with the scenario you describe that it helps to debug unsuccessful exits.
However, adding to every single exit function a TODO now is not reasonable. Doing this in every exit function would increase the number of TODOs unnecessarily. Instead - if there is a good working way to handle a failing exit except system reset :) - raise an issue to equip all the exit functions with a return value again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO shall be removed and issue shall be raised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue has been raised: #234
ret = destroyTimestampShm(); | ||
if (ret != kErrorOk) | ||
{ | ||
DEBUG_LVL_ERROR_TRACE("%s() exit failed", __func__); // TODO:Handle ret value in upper layers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop that TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user tries to re run the POWERLINK application after an unsuccessful "POWERLINK exit" he will be facing errors due to improper exit, so the previous error handling traces will support the user to debug and progress further.
Hence it is necessary to handle the return value in the upper layers as well, so the TODO is essential here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here...
DEBUG_LVL_ERROR_TRACE("%s() Initialization of shared memory failed!\n", | ||
__func__); | ||
// Close the semaphore | ||
sem_close(instance_l.syncSem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the semaphore cleanup outside of this function!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled semaphore clean up outside the function, instead the handling is done using goto statements inside the same function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
// Close the semaphore | ||
sem_close(instance_l.syncSem); | ||
// Unlink the semaphore and timesync shared memory | ||
sem_unlink(TIMESYNC_SYNC_BSDSEM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the semaphore cleanup outside of this function!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled semaphore clean up outside the function, instead the handling is done using goto statements inside the same function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
#if defined(CONFIG_INCLUDE_SOC_TIME_FORWARD) | ||
ret = createTimestampShm(); | ||
if (ret != kErrorOk) | ||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do semaphore cleanup here if createTimestampShm() fails!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled semaphore clean up outside the function, instead the handling is done using goto statements inside the same function itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
timestamps using mmap.
function.
This pull request also takes care of the comments from the previous pull request #227