Re: pipes



Rainer Weikusat wrote:
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.


That's too easy... :-)

One last question about the "real time" aspect of this:

I only have one process that would write to this area. So if in the server I set

p[0] = -1;
write ...
p[0] = 0;

then the client would know not to try to read the area until p[0] == 0. Would this work? Or are the writes buffered somehow?

Thanks!

--Yan
.



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
    ... I think mmap is easier to use. ... 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)
  • 4.9 mount_smbfs
    ... I have a samba share mounted with mount_smbfs. ... Afterwards if I open a file on this share from ... own until I close this file on the other client. ... Both the server and client are 4.9 with same ...
    (freebsd-questions)
  • Re: What doesnt lend itself to OO?
    ... >> proxy and instructs the server to constuct the real object. ... rather than client code. ... If 'clock' is instantiated in the server, ... > for the server interface at the OOA level. ...
    (comp.object)
  • This is going straight to the pool room
    ... or not the client has privilege to do what they're trying to do, ... The server environment is this: ... 3GL User action Routines that Tier3 will execute on your behalf during the ... Routine Name: USER_INIT ...
    (comp.os.vms)