Seagate ST3500630A Serial ATA Native Command Queuing (670K, PDF) - Page 10

Conclusion

Page 10 highlights

Serial ATA Native Command Queuing &overlap); // Contains event and offset for asynchronous // operation // // Make sure there was not an error. // if ((ERROR_SUCCESS != bStatus) || (ERROR_IO_PENDING != bStatus)) { fprintf(stderr, "ReadFile call failed.\n"); ExitProcess(); } // // Make more IO calls or do other useful work. // ... // // Check that the IO has been completed. Note that multiple completions can be // checked for at the same time. // dwResult = WaitForMultipleObjects( n, // Number of IOs issued handleArray, // Array of handles to the events in the // overlapped structure for each IO TRUE, // Wait for all IOs to be completed, could // wait for first to complete and then act on // that data, then check for more 50); // Wait up to 50 milliseconds for completion, // could be infinity. // // Check the value of dwResult and also call GetOverlappedResult to ensure // that each IO that completed was with good status. // ... As can be seen from this example, asynchronous I/O involves more code and can seem a bit cumbersome. However the performance potential of combining queuing with asynchronous IO is worth the extra lines of code. Conclusion Native Command Queuing has the potential to offer significant performance advantages. The benefits of NCQ are realized when a queue of commands is built up in the drive such that the drive can optimally re-order the commands to reduce both seek and rotational latency. NCQ delivers an efficient solution through features in the Serial ATA protocol including race-free status return, interrupt aggregation, and First Party DMA. 10

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Serial ATA Native Command Queuing
&overlap);
// Contains event and offset for asynchronous
// operation
//
// Make sure there was not an error.
//
if ((ERROR_SUCCESS != bStatus) || (ERROR_IO_PENDING != bStatus))
{
fprintf(stderr, “ReadFile call failed.\n”);
ExitProcess();
}
//
// Make more IO calls or do other useful work.
//
...
//
// Check that the IO has been completed.
Note that multiple completions can be
// checked for at the same time.
//
dwResult = WaitForMultipleObjects(
n,
// Number of IOs issued
handleArray,
// Array of handles to the events in the
// overlapped structure for each IO
TRUE,
// Wait for all IOs to be completed, could
// wait for first to complete and then act on
// that data, then check for more
50);
// Wait up to 50 milliseconds for completion,
// could be infinity.
//
// Check the value of dwResult and also call GetOverlappedResult to ensure
// that each IO that completed was with good status.
//
...
As can be seen from this example, asynchronous I/O involves more code and can seem a bit
cumbersome.
However the performance potential of combining queuing with asynchronous IO is
worth the extra lines of code.
Conclusion
Native Command Queuing has the potential to offer significant performance advantages.
The
benefits of NCQ are realized when a queue of commands is built up in the drive such that the
drive can optimally re-order the commands to reduce both seek and rotational latency.
NCQ
delivers an efficient solution through features in the Serial ATA protocol including race-free status
return, interrupt aggregation, and First Party DMA.
10