michallenc opened a new pull request, #18816:
URL: https://github.com/apache/nuttx/pull/18816

   ## Summary
   Setting the current time in RTC may be a blocking operation (driver needs to 
wait for oscillator stabilization after reset and so on). This may cause the 
unwanted effect of `clock_settime` blocking the code execution for a 
considerable amount of time.
   
   The solution is to plan a low priority work that takes care of setting the 
time in RTC and let `clock_settime` continue. We don't have to check if the 
work is available, just cancel it if there is a new time set request.
   
   This is used only if `CONFIG_SCHED_LPWORK` is enabled. I was thinking about 
putting this under a special separate config option, but it seems like 
something you always want if you have LPWORK - but feel free to suggest 
otherwise, I am not against creating an option solely for this.
   
   ## Impact
   
   `clock_settime` now shouldn't block the code execution.
   
   ## Testing
   
   We encountered this with `mcp794xx` RTC - the controller waits until the 
oscillator is started, which may take tens of milliseconds (we measured up to 
~40 ms on oscilloscope delay). This caused issue in a customer's custom 
protocol implementation - we receive the current time, set it and response with 
status message - but there were timeouts in the communication if time was set.
   
   The issue no longer occurs if RTC set time is done in a separate work thread 
as `clock_settime` doesn't block.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to