anchao commented on PR #12319:
URL: https://github.com/apache/nuttx/pull/12319#issuecomment-2105415738

   > @anchao are these new functions compatible with POSIX? I searched for it 
and this doesn't exist. Is it is possible to implement is in a way that we use 
same function and it detects if we are using abstime or ticktime and it use the 
right function?
   > 
   > Also, if you are adding a new API, please update the Documentation/
   > 
   > https://nuttx.apache.org/docs/latest/reference/user/04_message_queue.html
   
   @acassis 
   
   The newly implemented function is an extension of the OS internal API. It 
has an alias with the file_ prefix and is mainly used in the kernel code:
   
   POSIX:
   ```
   mq_timedsend
   mq_timedreceive
   ```
   
   NuttX Kernel API:
   
   ```
   file_mq_timedsend
   file_mq_timedreceive
   ```
   
   Newly added by this PR:
   ```
   file_mq_ticksend
   file_mq_tickreceive
   ```
   
   Why add such an API?
   
   Kernel code usually uses relative time to calculate timeout, but the POSIX 
mq interface uses absolute time and must convert to timespec. Based on this 
limitation, there will be a lot of code to convert ticks into real time, which 
is implemented in file_mq_timedreceive Within, real timespec converted to 
relative time again:
   
   ```
   clock_gettime(CLOCK_REALTIME, &timeout);
   |
   timeout += MSEC2TICK(block_time_ms);
   |
   file_mq_timedreceive(timeout);
   |
    ->clock_abstime2ticks(timeout);
      |
       ->wd_start(ticks)
   ```
   
   The new API will reduce this time conversion overhead:
   
   ```
   file_mq_tickreceive(MSEC2TICK(block_time_ms))
   |
    ->wd_start(ticks)
   ```
   
   Such code exists in the esp32 code:
   
   
https://github.com/apache/nuttx/blob/master/arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c#L1285-L1291


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