can multiple threads of same function be created to process large arrays in small blocks?
可以创建多个具有相同功能的线程来处理小块中的大型数组吗?
i am trying to do it in Linux C, assume i have read() it is reading data from serial into array, when array is full it is passed for processing to stable(), meanwhile it is processed, read should be reading new data, because stable() is taking long to process old data, so newly created thread of stable() should be processing new data available in array.
我正在尝试在Linux C中执行此操作,假设我已读取()它正在将数据从串行读入数组,当数组已满时将其传递给处理为stable(),同时将其处理,读取应读取新数据,因为stable()需要很长时间来处理旧数据,所以新创建的stable()线程应该处理数组中可用的新数据。
problem is i am confused, can i create two threads of stable() in Linux C?
问题是我很困惑,我可以在Linux C中创建两个线程的stable()吗?
1 个解决方案
#1
0
Each thread created using the pthreads API specifies an entry point that should match the standard signature:
使用pthreads API创建的每个线程都指定了一个与标准签名匹配的入口点:
void *entry(void *)
{
return 0;
}
Once that entry point has been called, you can invoke anything that you want including the stable() routine that you referenced above. You will need to be careful, however, to ensure that stable() and anything that it calls is thread safe.
调用该入口点后,您可以调用所需的任何内容,包括上面引用的stable()例程。但是,您需要注意确保stable()和它调用的任何东西都是线程安全的。
#1
0
Each thread created using the pthreads API specifies an entry point that should match the standard signature:
使用pthreads API创建的每个线程都指定了一个与标准签名匹配的入口点:
void *entry(void *)
{
return 0;
}
Once that entry point has been called, you can invoke anything that you want including the stable() routine that you referenced above. You will need to be careful, however, to ensure that stable() and anything that it calls is thread safe.
调用该入口点后,您可以调用所需的任何内容,包括上面引用的stable()例程。但是,您需要注意确保stable()和它调用的任何东西都是线程安全的。