xiaoxiang781216 commented on pull request #4193:
URL: https://github.com/apache/incubator-nuttx/pull/4193#issuecomment-884376930


   > Another thing that we will have to be careful with is in reading and 
writing 64-bit values. On a 32-bit ARMv7-M CPU, 64-bit access are not atomic. 
The CPU can be interrupted or the task can be suspended between each 32-bit 
access and this may result in a corrupted access.
   > 
   > Every 64-bit access must be protected so that it completes without 
modification at the interrupt level or by other tasks. sched_lock() is probably 
sufficient in most non-SMP cases. Inside of file system logic, re-entrancy 
protections may also be sufficient (?)
   > 
   > 64-bit accesses are atomic on ARMv7-A and probably other ARMs and other 
CPU architectures. Unfornately, ARMv7-M is most prevalent in the 32-bit 
embedded world.
   
   Even off_t is 32bit, the programmer still need be careful in the multithread 
environment, since fs driver normally add the write/read len to the current 
offset, but += operator is never atomic on any hardware.


-- 
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