Re: using pipe
- From: "Maxim Yegorushkin" <maxim.yegorushkin@xxxxxxxxx>
- Date: 26 Oct 2006 00:48:54 -0700
junky_fellow@xxxxxxxxxxx wrote:
On Oct 25, 4:32 pm, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:
junky_fel...@xxxxxxxxxxx <junky_fel...@xxxxxxxxxxx> wrote:
On Oct 25, 3:37 pm, loic-...@xxxxxxx wrote:
I wanted to know if the "pipe" can only be used for data transmission from one processrelated processes.
to another (parent to child and viceversa) ?Yes, pipe can be used as Inter-Process Communication (IPC) between
Can a pipe be used to transfer data in the same prcoess ?This could done, albeit this can be tricky.
limited size (in the order of a few kBs). They're not meant as a wayI don't want to use a buffer to store the output, as the output sizeFor instance, I want to execute some function and want to save its
output to a pipe then in the same process, I need to read the output from this
pipe to some buffer (one string at a time). Can this be done ?
I beg your pardon. But why not using directly a buffer for that? The
may be huge (saveral MBs).Then you definitely can't use pipes. A pipe typically has a rather
to obtain some temporary storage.
I want to keep this in a pipe (believing pipe takes storage from theis a FIFO, not a pipe) is slow. Why not use memory, obtained by e.g.
file system).Going through the file system (and I guess what you were looking for
malloc(), and let the system take care of swapping out that parts
of the memory that don't fit anymore and aren't needed at the moment?
While I haven't done any tests I would guess that this might be faster
- only writing to disk when necessary and using probably highly opti-
mized algorithms for doing it when there's no alternative. And I
probably would start with thinking about a linked list of the strings,
so you don't need a single huge block of memory that grows and shrinks
(possibly requiring to copy the whole thing when you need to increase
its size).
I can't use malloc due to some design restriction. I have to use some
files to store the
command output temporarily and later read the file to get the output.
Can I use memory file sustems to store these files? I believe
reading/writing from memory
file systems would be faster. But, I am not aware of any negative
impact of mfs on the system.
Is it a good idea to use mfs to stoe these files ?.
Did you think of mapped memory?
You could create an anonymous or named memory mapping. On Linux, for
example, memory mappings created by shm_open are backed by tmpfs
filesystem and you can use them just as regular files. shm_open ->
(ftruncate -> mmap -> munmap)* -> close -> shm_unlink.
.
- References:
- using pipe
- From: junky_fellow@xxxxxxxxxxx
- Re: using pipe
- From: loic-dev
- Re: using pipe
- From: junky_fellow@xxxxxxxxxxx
- Re: using pipe
- From: Jens Thoms Toerring
- Re: using pipe
- From: junky_fellow@xxxxxxxxxxx
- using pipe
- Prev by Date: Re: using pipe
- Next by Date: Re: Are twalk/tfind/tdelete/tsearch POSIX
- Previous by thread: Re: using pipe
- Next by thread: fread
- Index(es):
Relevant Pages
|