2

CreateFile を使用して (Windows プラットフォームの C++ で) シリアル ポート接続を開く場合、重複して開くか、重複しないで開くかを選択できます。

重複していない ReadFile として開かれた場合、または WriteFile 呼び出しがブロックされている場合、つまり、準備が整うまで返されません。

私の質問は、これらの関数呼び出しが別々のスレッドで実行されたときに互いにブロックするかどうかです。1 つのスレッドが ReadFile を実行する場合、すべての読み取りが完了する前に、別のスレッドが WriteFile を実行できますか?

4

1 に答える 1

0

Yes, they do. From MSDN:

"If one thread is blocked waiting for its I/O operation to complete, all other threads that subsequently call a communications API will be blocked until the original operation completes. For instance, if one thread were waiting for a ReadFile function to return, any other thread that issued a WriteFile function would be blocked."

(http://msdn.microsoft.com/en-us/library/ff802693.aspx#serial_topic4)

于 2014-10-02T23:03:29.560 に答える