Re: Removing access to parts of memeory
On Oct 1, 10:13 pm, "Alf P. Steinbach /Usenet" <alf.p.steinbach
* Kasper Middelboe Petersen, on 01.10.2010 20:39:
I'm working on a CSP library.
Which of the acronyms at <url:http://acronyms.tfd.com/Csp> is *your* "CSP"?
OK, I'll make an educated guess, that you're talking about
Concurrent Sequential Processes in the sense of Hoare.
That would seem rather obvious (and I find it surprising that
people with your experience, or that of Victor, aren't familiar
with the acronym).
I have channels and communicate messages
between processes using these. I would really like to be able to
enforce the concepts of CSP by removing accesss to variables for one
process as its passed trough a channel to another somehow.
Which concept is that?
The concept of CSP. Basically, that a "job" consists of a set
of data and a sequence of steps, each step being handled by
a separate "process" (a process in CSP would typically be
a thread today). And only one process has access to the data of
I'm looking for any ideas as to how to actually do this.
It's unclear what you mean by "removing access to variables".
Just to examplify what I mean:
I have two processes, p1 and p2. They share a channel c of a datatype
d which p1 writes to and p2 reads from.
Now d could be very simple like a bool or int in which case copying
wouldnt be a real problem thus leaving p2 with its own copy of the
message that p1 does not in anyway have access to.
However more often than not it would be a larger datastructure which
would be passed as a pointer to avoid the overhead of copying. In this
case p1 ofcause passes a pointer trough the channel instead. Problem
is this means you have no problem accessing the same object from p1
after its send to p2 as the pointer remains valid.
It appears you're talking about a data structure placed in
shared memory, or, you're talking about threads, not
He's talking about the processes in CSP, not the processes in
Windows or in Unix. Processes in CSP are typically implemented
as threads; they could be implemented as processes, using shared
memory, but in that case, the solution to his problem is
obvious: unmap the shared memory from the process which has
passed the data on. (This is actually not a bad idea: maintain
all pertinent data in files which are mmap'ed. The channel
interface unmaps the file, and sends its name by some other
means, maybe a pipe, to the next process, which mmap's it.)
My question is, anyone have any ideas how to invalidate the pointer p1
has after its been send to p2? I'm willing to take some performane
hits all though not so much as to having to force a copy on every
Before thinking about performance, try to implement something that works.
I think you'll find that the performance problems you're
envisioning are not relevant, but that other performance
Independently of performance... Having to pass complex data
through a serial channel involves marshalling, which is a lot of
For a large scale, industrial application, I'd certainly look
into the mmap'ed solution, with custom allocators so that
I could use things like std::vector in the client data. But
such a solution is a lot of work, and just using auto_ptr at the
channel interface has been sufficient in numerous applications