Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with "FIFO" in C# .NET?

Tags:

c#

.net

fifo

Is there a standard collection in .NET that implements a FIFO stack?

like image 826
Rella Avatar asked Jun 03 '10 13:06

Rella


People also ask

What is FIFO in C programming?

FIFO is an abbreviation for first in, first out. It is a method for handling data structures where the first element is processed first and the newest element is processed last.

How do you make FIFO?

FIFOs are created using mknod(2), mkfifo(3C), or the mknod(1M) command. They are removed using unlink(2) or the rm(1) command. FIFOs look like regular file system nodes, but are distinguished from them by a p in the first column when the ls -l command is run.

How do you read FIFO?

When a user process attempts to read from an empty pipe (or FIFO), the following happens: If one end of the pipe is closed, 0 is returned, indicating the end of the file. If the write side of the FIFO has closed, read(2) returns 0 to indicate the end of the file.

How FIFO is used in IPC?

Using FIFO: As named pipe(FIFO) is a kind of file, we can use all the system calls associated with it i.e. open, read, write, close. Example Programs to illustrate the named pipe: There are two programs that use the same FIFO. Program 1 writes first, then reads. The program 2 reads first, then writes.


2 Answers

FIFO means first-in-first-out. The data structure you're looking for is called a Queue.

like image 195
Dave Markle Avatar answered Sep 25 '22 00:09

Dave Markle


FIFO means first in first out. This is as opposed to LIFO (or FILO as lucero pointed out). which is last in first out.

A link comparing queues, stacks, and hashtables.

You want to use a queue object for FIFO operations:

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=66

MSDN link on queues

And a stack is used for LIFO operations: Stack Link

like image 39
kemiller2002 Avatar answered Sep 22 '22 00:09

kemiller2002