Re: pipes



CptDondo <yan@xxxxxxxxxxxxxxxx> writes:

[...]

From what I gather, I'm better off using BSD mmap, rather than SysV
IPC... Right?

I think mmap is easier to use.

And in essence, all I have to do on the server is something like:

fd = open(somefile,O_WRONLY);
mmap(some block, PROT_WRITE....,fd)

then write to fd and do a msync????

Assuming a suitable file exists:

fd = open(somefile, O_RDWR);
p = mmap(NULL, length_of_data, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, 0);
close(fd)

Afterwards, you can just use the memory area pointed to by 'p' like
any other memory area.

On the client,

fd = open(somefile,O_RDONLY);
mmap(some block, PROT_READ....,fd)

fd = open(somefile, O_RDONLY);
p = mmap(NULL, length_of_data, PROT_READ, MAP_SHARED, fd, 0);
close(fd);

Both 'client p' and 'server p' will point the same area of physical
memory from now on. 'msync' is only needed if you want to ensure that
changes are written to disk. You will need to come up with some sort
of 'access protocol' to ensure that the client doesn't read from the
same part of this area the server is currently writing to.

.



Relevant Pages

  • Re: pipes
    ... any other memory area. ... of 'access protocol' to ensure that the client doesn't read from the ... same part of this area the server is currently writing to. ... Since file locking is designed for exactly this sort ...
    (comp.unix.programmer)
  • Re: pipes
    ... Afterwards, you can just use the memory area pointed to by 'p' like ... Both 'client p' and 'server p' will point the same area of physical ...
    (comp.unix.programmer)
  • mmap syscall problem
    ... I am trying to solve problem with mmap syscall on Microblaze which I have. ... The memory area beyond the end of file to the end of page should be ... Delete the temporary directory created. ... cleanup() - performs all ONE TIME cleanup for this test at ...
    (Linux-Kernel)
  • Re: The crux of peoples issues with PLT Scheme?
    ... doc says the following in the opening sentence with regard to mmap: ... This memory area can ... performance in comparison with equivalent code using regular ports. ...
    (comp.lang.scheme)