fifo

Linux non-blocking fifo (on demand logging)

情到浓时终转凉″ 提交于 2019-11-27 06:30:31
I like to log a programs output 'on demand'. Eg. the output is logged to the terminal, but another process can hook on the current output at any time. The classic way would be: myprogram 2>&1 | tee /tmp/mylog and on demand tail /tmp/mylog However, this would create a ever growing log file even if not used until the drive runs out of space. So my attempt was: mkfifo /tmp/mylog myprogram 2>&1 | tee /tmp/mylog and on demand cat /tmp/mylog Now I can read /tmp/mylog at any time. However, any output blocks the program until the /tmp/mylog is read. I like the fifo to flush any incoming data not read

Which STL container should I use for a FIFO?

青春壹個敷衍的年華 提交于 2019-11-27 06:15:40
Which STL container would fit my needs best? I basically have a 10 elements wide container in which I continually push_back new elements while pop_front ing the oldest element (about a million time). I am currently using a std::deque for the task but was wondering if a std::list would be more efficient since I wouldn't need to reallocate itself (or maybe I'm mistaking a std::deque for a std::vector ?). Or is there an even more efficient container for my need? P.S. I don't need random access GManNickG Since there are a myriad of answers, you might be confused, but to summarize: Use a std::queue

Reading a file in real-time using Node.js

╄→尐↘猪︶ㄣ 提交于 2019-11-27 04:24:27
问题 I need to work out the best way to read data that is being written to a file, using node.js, in real time. Trouble is, Node is a fast moving ship which makes finding the best method for addressing a problem difficult. What I Want To Do I have a java process that is doing something and then writing the results of this thing it does to a text file. It typically takes anything from 5 mins to 5 hours to run, with data being written the whole time, and can get up to some fairly hefty throughput

Create a temporary FIFO (named pipe) in Python?

徘徊边缘 提交于 2019-11-27 01:25:38
How can you create a temporary FIFO (named pipe) in Python? This should work: import tempfile temp_file_name = mktemp() os.mkfifo(temp_file_name) open(temp_file_name, os.O_WRONLY) # ... some process, somewhere, will read it ... However, I'm hesitant because of the big warning in Python Docs 11.6 and potential removal because it's deprecated. EDIT : It's noteworthy that I've tried tempfile.NamedTemporaryFile (and by extension tempfile.mkstemp ), but os.mkfifo throws: OSError -17: File already exists when you run it on the files that mkstemp/NamedTemporaryFile have created. mhawke os.mkfifo()

real time scheduling in Linux

一世执手 提交于 2019-11-26 22:37:37
问题 This morning I read about Linux real time scheduling. As per the book 'Linux system programming by Robert Love', there are two main scheduling there. One is SCHED_FIFO, fifo and the second is SCHED_RR, the round robin. And I understood how a fifo and a rr algorithm works. But as we have the system call, sched_setscheduler (pid_t pid, int policy, const struct sched_parem *sp) we can explicitly set the scheduling policy for our process. So in some case, two process running by root, can have

Linux non-blocking fifo (on demand logging)

二次信任 提交于 2019-11-26 22:15:51
问题 I like to log a programs output 'on demand'. Eg. the output is logged to the terminal, but another process can hook on the current output at any time. The classic way would be: myprogram 2>&1 | tee /tmp/mylog and on demand tail /tmp/mylog However, this would create a ever growing log file even if not used until the drive runs out of space. So my attempt was: mkfifo /tmp/mylog myprogram 2>&1 | tee /tmp/mylog and on demand cat /tmp/mylog Now I can read /tmp/mylog at any time. However, any

单口RAM、双口RAM、FIFO

偶尔善良 提交于 2019-11-26 20:02:32
单口与双口的区别在于,单口只有一组数据线与地址线,因此读写不能同时进行。而双口有两组数据线与地址线,读写可同时进行。FIFO读写可同时进行,可以看作是双口。 双口RAM分伪双口RAM(Xilinx称为Simple two-dual RAM)与双口RAM(Xilinx称为true two-dual RAM)。伪双口RAM,一个端口只读,另一个端口只写;而双口RAM两个端口都可以读写。 FIFO也是一个端口只读,另一个端口只写。FIFO与伪双口RAM的区别在于,FIFO为先入先出,没有地址线,不能对存储单元寻址;而伪双口RAM两个端口都有地址线,可以对存储单元寻址。 异步时钟域的缓存只要是双口器件都可以完成。但FIFO不需对地址进行控制,是最方便的。 摘录: 根据我的设计经验,其实FIFO的核心还是一片RAM。只不过把RAM的操作封装了一下,添加了两个指针,也就是两个地址寄存器,一个写地址寄存器,一个读地址寄存器。 当FIFO初始化时,读地址寄存器和写地址寄存器皆为零; 当FIFO写一个数据时,把数据写入当前地址寄存器指向的RAM地址,然后写地址寄存器加1;如果加到RAM的底部了,就再次变为零; 当FIFO读数据时,把读地址寄存器的数据读出来,然后读地址寄存器加1;如果读到RAM的底部了,就再次变为零; 如果读地址寄存器追上写地址寄存器,就说明读空了,没数据可读了;

Why does a read-only open of a named pipe block?

戏子无情 提交于 2019-11-26 19:05:33
问题 I've noticed a couple of oddities when dealing with named pipes (FIFOs) under various flavors of UNIX (Linux, FreeBSD and MacOS X) using Python. The first, and perhaps most annoying is that attempts to open an empty/idle FIFO read-only will block (unless I use os.O_NONBLOCK with the lower level os.open() call). However, if I open it for read/write then I get no blocking. Examples: f = open('./myfifo', 'r') # Blocks unless data is already in the pipe f = os.open('./myfifo', os.O_RDONLY) #

NSOperationQueue serial FIFO queue

末鹿安然 提交于 2019-11-26 18:18:42
问题 Is it possible to use an NSoperationQueue object as a serial FIFO queue by setting its maxConcurrentOperationCount to 1? I note that the docs state... For a queue whose maximum number of concurrent operations is set to 1, this equates to a serial queue. However, you should never rely on the serial execution of operation objects. Does this mean that FIFO execution is not guaranteed? 回答1: In most cases, it will be FIFO. However, you can set up dependencies between NSOperations such that an

Create Named Pipe C++ Windows

青春壹個敷衍的年華 提交于 2019-11-26 17:58:27
问题 I am trying to create a simple comunication between 2 processes in C++ ( Windows ) like FIFO in linux. This is my server: int main() { HANDLE pipe = CreateFile(TEXT("\\\\.\\pipe\\Pipe"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); ConnectNamedPipe(pipe, NULL); while(TRUE){ string data; DWORD numRead =1 ; ReadFile(pipe, &data, 1024, &numRead, NULL); cout << data << endl; } CloseHandle(pipe); return 0; } And this is my client: int main() { HANDLE pipe = CreateFile(TEXT("\