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

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

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

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Korona
Member
Member
Posts: 999
Joined: Thu May 17, 2007 1:27 pm
Contact:

Post 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.
z180
Member
Member
Posts: 32
Joined: Tue Mar 04, 2008 12:32 pm

Post 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.
Post Reply