Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C语言中的线程间通信_C_Multithreading_Pthreads - Fatal编程技术网

C语言中的线程间通信

C语言中的线程间通信,c,multithreading,pthreads,C,Multithreading,Pthreads,作为我项目的一部分,我必须使用线程修改一个数值积分算法 这大致上就是传统顺序方法中发生的情况 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 solut

作为我项目的一部分,我必须使用线程修改一个数值积分算法

这大致上就是传统顺序方法中发生的情况

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

这是一个广泛的主题,但这里有一些提示

  • -基本上创建一组线程并有一个任务队列。他们从队列中选一个来做这项工作
  • IPC-这里有信号量、共享内存、消息传递。链接在网上

  • 维基百科会让你走的。

    量化“一堆线索”是值得的。如果创建太多,将对性能产生负面影响。每个CPU核心至少有一个线程是一个很好的起点。