Re: pipes



On Wed, 29 Aug 2007 12:39:48 -0700, CptDondo wrote:

Rainer Weikusat wrote:

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

This "write" does not exist; at least the programs can't
detect whether is happened or not. The programs just "peek" into the same
diskbuffer. Whether that diskbuffer has been written to the disk or not is
irrelevant.


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?


No. The only possible buffering is done by the compiler. This is what the
'volatile' keyword is all about. AFAIK, writes of machine-words are atomic.
Reads/writes to disks are atomic, too; (modulo pagesize). This can only be
violated by a hardware crash.

So, you are safe if there is a flag or pointer that is writable
by only the writer-process. (See also Lamport
http://research.microsoft.com/users/lamport/pubs/pubs.html#bakery
or http://research.microsoft.com/users/lamport/pubs/pubs.html#rd-wr )

HTH,
AvK
.



Relevant Pages

  • Re: Certain files gets corrupted after being copied with RDC
    ... up 88 KB on disk. ... We have a customer that is experiencing the same problem with PDF files. ... try to copy certain file types from a Windows Server 2008 x64 running TS ... open it on the client it won't work. ...
    (microsoft.public.windows.terminal_services)
  • Re: File Redirection
    ... It was possible with the older client by installing the neccessary files from ... the win2k resource disk and I could have sworn that, initially, I was able to ... I can no longer copy files from workstation to server or server to ... >> checking the disk drives box under the Local Resources tab, ...
    (microsoft.public.windows.terminal_services)
  • Re: Free software for MS-DOS -> XP parallel cable link?
    ... >I searched more for parallel cable software, ... machine into a server and the other into a client via the serial port ... as if a disk on the server were connected to the client. ... ENTIRE contents of a 500-meg disk from one machine to another (taking ...
    (comp.os.msdos.misc)
  • Re: pipes
    ... Both 'client p' and 'server p' will point the same area of physical ... Whether that diskbuffer has been written to the disk or not is ...
    (comp.unix.programmer)
  • Setup Problem has anyone heard of this?
    ... I have an SBS 2003 Server at a clients office, ... "There are no active directory users" "add a user to the active directory and ... and a few other things that the client does not use right now. ...
    (microsoft.public.windows.server.sbs)