Page 1 of 1

Is it a pipe? Or is it a.....?

Posted: Wed Apr 02, 2008 8:45 am
by piranha
I created this thing and named a 'pipe' for want of a better name. My question, Is it a pipe? Does it fit the categories?
Creation: Allocates some memory and fills some info, then signals a pipe_created signal to all programs.
Reading: Reads from current_position to length and puts it into a buffer.
(you can set current_position)
Another question.....when reading some data, does that data get deleted? How does the kernel know what data is used so another program doesn't overwrite it?
Writing: Writes data from from buffer from current_position to length, then sends a PIPE_WRITTEN signal to all programs.

I'm considering re-naming it.....to......message, box, idk...something.

-JL

Posted: Wed Apr 02, 2008 9:35 am
by Korona
Thats similar to the way pipes are implemented in my operating system. They are just circular buffers in shared memory. The data structure itself is not a pipe but a simple buffer, but it can be used as a pipe. Operations on messages are usually atomic (the receiver either gets the full message or no message at all) so I would not call this structure a message box.
Another question.....when reading some data, does that data get deleted? How does the kernel know what data is used so another program doesn't overwrite it?
The easiest way to handle this is having two pointers/position counters: One pointer to the current "read offset" and one to the current "write offset". Usually a circular buffer is used for data structures like that. You don't have to delete the read data although there are some implementations that delete it, e.g. some lock-free pipe implementations.

Posted: Thu Apr 03, 2008 7:27 am
by z180
i have unix pipes in my system(because it is modeled after docs and manpages of different unix,bsd ,linux uzi,solais,minix...) but i dont use a socket like some bsd versions.I use a page sized shared buffer and my code is a small vfs that uses an inode and works for pipes and fifos.