0

私のプロジェクトの一部として、スレッドを使用して数値積分アルゴリズムを変更する必要があります。

これは、従来のシーケンシャル アプローチで大まかに起こることです。

void Controller(struct DE)
{
    //initialization step
    for(;;)   //till the entire range has not been covered...
    {
         //compute the next time-point solution using the previously known solutions.
         NIiter();
         //then check if the result is acceptable or not and take the necessary steps...
    }
}

今、これが私がやろうとしていることです....

void Controller(struct DE)
{
    //initialization step
    for(;;)   //till the entire range has been covered...
    {
         //compute the next time using the previously known solution.
         NIiter();
         //when I have an approximate solution available..launch a thread to compute the next time-point using this approximate solution as a previous solution...something like forward pipelining...
         //then check if BOTH the results are acceptable or not and take the necessary steps...
    }
}

しかし、おおよその解決策が利用可能であることをコントローラーに通知する方法がわかりません...新しいスレッドを起動できます...

これは、マルチスレッド プログラミングへの私の最初の暴露です...だから、これが明白な質問のように思われる場合は、私を許してください..また、私は自分のプロジェクトで Pthread ライブラリを使用しています...

4

1 に答える 1

1

これは広大なトピックですが、ここにいくつかの指針があります

  1. ワーカー スレッド- 基本的に、一連のスレッドを作成し、タスクのキューを持ちます。彼らはキューの1つを取り、仕事をします
  2. IPC - ここには、セマフォ、共有メモリ、メッセージの受け渡しがあります。リンクはページ内にあります

ウィキペディアがあなたを導きます。

于 2012-11-04T10:36:48.197 に答える