fifo

Reading from FIFO after unlink()

十年热恋 提交于 2019-12-23 09:50:30
问题 I have created a FIFO, wrote to it and unlinked it. To my surprise I was able to read data from the fifo after unlinking, why is that? #include <fcntl.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #define MAX_BUF 256 int main() { int fd; char * myfifo = "/tmp/myfifo"; /* create the FIFO (named pipe) */ mkfifo(myfifo, 0666); int pid = fork(); if (pid != 0) { /* write "Hi" to the FIFO */ fd = open(myfifo, O_WRONLY); write(fd, "Hi",

Stack Empty Exception

本小妞迷上赌 提交于 2019-12-23 09:16:29
问题 I am getting a stack empty exception. How is that possible if the stack is not empty (it has 16 items)? I got a snap shot of the error: Can someone please explain? 回答1: You must synchronize access when using something like Stack<T> . The simplest approach is to use lock , which then also let's you use the lock for the synchronization itself; so pop would be: int item; lock (SharedMemory) { while (SharedMemory.Count == 0) { Monitor.Wait(SharedMemory); } item = SharedMemory.Pop(); } Console

Node.js fs.open() hangs after trying to open more than 4 named pipes (FIFOs)

依然范特西╮ 提交于 2019-12-22 18:50:36
问题 I have a node.js process that needs to read from multiple named pipes fed by different other processes as an IPC method. I realized after opening and creating read streams from more than four fifos, that fs seems to no longer be able to open fifos and just hangs there. It seems that this number is a bit low, considering that it is possible to open thousands of files concurrently without trouble (for instance by replacing mkfifo by touch in the following script). I tested with node.js v10.1.0

a FIFO query in SQL Server

偶尔善良 提交于 2019-12-22 17:55:26
问题 I'm building a stock management app in c# with SQL server . I want to make a FIFO query from my table. I purchased same products in variable rate. After that I sold some of them. I want to query based in "First in first out" according to BatchDate column. So I want to get the available in stock products with PurchasePrice. Here is my table: ` CREATE TABLE InventoryLedgers ( BatchNo nvarchar(30), BatchDate datetime, ProductId int, StockIn decimal(18, 2), StockOut decimal(18, 2), PurchasePrice

Detect when a fifo is opened from a program

自作多情 提交于 2019-12-22 11:14:18
问题 I have a situation where I need to check if the other side of a fifo has opened it, however I can't use a open because otherwise the program will start doing stuff. Why I have to do this: I have a program (a monitor) that launches a server program (both created by me). The monitor uses this fifo to communicate beacause the monitor can be closed/reopened while the server is already started. The problem is when the monitor starts the server: in this case I have to wait in some way for fifos to

Write/Read to/from FIFO files - linux

谁都会走 提交于 2019-12-22 07:44:31
问题 I've been trying to wrap my head around FIFO, and came up with a simple program of server and client. I'm not trying to do anything fancy, just to have one process that will play a role of 'server', this process will 'listen' to any messages delivered by another process; the client. Here's what I wrote: server.c #include<stdio.h> #include <fcntl.h> #include <stdlib.h> #define INGOING "clientToServer.fifo" #define BUFFER 200 int main(int argc, char *argv[]) { char in[BUFFER]; mkfifo(INGOING,

MySQL table as a FIFO/Queue

两盒软妹~` 提交于 2019-12-21 22:07:45
问题 How can we treat a Mysql table as a limited FIFO buffer (Queue). Objectives are : The table at a time can have only N number of rows. When a row is inserted, the oldest row shpuld be deleted to maintain the row count as N. Pls suggest approaches. UPDATE: Sorry guys, as many pointed I changed my question from STACK to FIFO queue 回答1: Past Mysql 5 you could use a trigger to achieve this. http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html then your triggered sql would be along the lines

Why is LRU better than FIFO?

我只是一个虾纸丫 提交于 2019-12-21 19:57:18
问题 Why is Least Recently Used better than FIFO in relation to page files? 回答1: If you mean in terms of offloading memory pages to disk - if your process is frequently accessing a page, you really don't want it to be paged to disk, even if it was the very first one you accessed. On the other hand, if you haven't accessed a memory page for several days, it's unlikely that you'll do so in the near future. If that's not what you mean, please edit your question to give more details. 回答2: There is no

Using fifo open in non-blocking mode with select

霸气de小男生 提交于 2019-12-21 12:58:13
问题 I have two processes A and B. The communication flow is always A -> B, but I need to do it using a named pipe, because I must use the pipe file descriptor in a select call inside the B process, and the data written to the pipe must persist when any or both of the processes exit. The pipe is opened in non-blocking mode on both ends. In process A: int push_fifo_fd = open(FIFO_NAME, O_WRONLY | O_NONBLOCK | O_CREAT, 0644); In process B: int fd = open(FIFO_NAME, O_RDONLY | O_NONBLOCK | O_CREAT,

Best approach to FIFO implementation in a kernel OpenCL

青春壹個敷衍的年華 提交于 2019-12-21 05:46:15
问题 Goal: Implement the diagram shown below in OpenCL. The main thing needed from the OpenCl kernel is to multiply the coefficient array and temp array and then accumilate all those values into one at the end. (That is probably the most time intensive operation, parallelism would be really helpful here). I am using a helper function for the kernel that does the multiplication and addition (I am hoping this function will be parallel as well). Description of the picture: One at a time , the values