简体   繁体   English

将输出从文件重定向到三个运行线程

[英]redirect output from file to three running thread

I want to use 'cat myclip.avi' command to send the output to three running thread, i am trying to process same clip file to produce three different result. 我想使用“ cat myclip.avi”命令将输出发送到三个正在运行的线程,我正在尝试处理同一剪辑文件以产生三个不同的结果。 can i use dup2 or how i can make pipe with thread not fork? 我可以使用dup2还是如何使带螺纹的管道不是叉子?

Sorry about the question being so vague. 很抱歉这个问题含糊不清。 Maybe I need to reinforce my understanding of dup2. 也许我需要加强对dup2的理解。 actually i am using external application let say "linux cat" to read data that in thread one, then data have to pass to two other thread to process it, also those are using external application let say "sort ascending" and "sort descending" assume sort application accept only pip in only, what do then? 实际上,我使用外部应用程序时说“ linux cat”读取线程1中的数据,然后数据必须传递到其他两个线程来处理它,也使用外部应用程序的人时说“排序升序”和“排序降序”假设排序应用程序仅接受点数,那该怎么办?

"How can I make pipe with thread not fork?" “如何使带螺纹的管道不叉?” You can't make a pipe with either fork or thread; 不能用叉子或螺纹制作管子; you make a pipe with pipe. 你用管子做管子。 Suppose you have 3 total threads, each with access to the same data. 假设您共有3个线程,每个线程都可以访问相同的数据。 One thread reads data into a buffer and uses the data. 一个线程将数据读入缓冲区并使用该数据。 It then blocks (on a mutex of some sort) until the other two threads each use the data. 然后,它将阻塞(在某种互斥锁上),直到其他两个线程各自使用数据为止。 Repeat. 重复。 Since you are using threads, you don't need a pipe at all. 由于使用的是线程,因此根本不需要管道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM