I have just written a short article on comp.programming.threads
about how Felix fthread cannot deadlock.

As a result of thinking about this, I have discovered a new issue
with channel operation.

At present, when two fthreads rendezvous on a channel,
Felix restarts the last thread to make a request first.

This requires the data pointer transferred to refer to
heap allocated data.  This is because if the writer
gains control first, the pointed at data may go out of
scope before the reader can read it.

This can be fixed by ensuring the reader always gains
control first, and requiring the reader actually
copy the pointed at data, before blocking again.

In turn, this is actually NOT necessary if the data
is heap allocated.

Now to backtrack, Felix currently only supports a 
typed bidirectional schannel concept. It would be easy
enough to amend the type system with two new types,
read-channel, write-channel, and allow one to upcast
a bidirectional channel to one of these. In particular
a routine that provides a read/write pair. Obviously
read channels don't support writing and write channels
don't support reading.

In addition, we might also distinguish strong and
weak channels. A weak channel being one that requires
the reader to regain control first and actually
copy the data. This can be enforced by a read routine
like the current one that actually does do that.

Weak readers can accept weak pointers (that is,
ordinary C pointers).

Weak operations are 'purely functional' in that they
transfer values.

A strong reader requires a gc pointer, but doesn't
need to copy the data, so it can be used to exchange
a reference to a mutable data structure such as a buffer.

Finally, some syntax to support anonymous channels
and producer consumer pairs .. that is .. filters ..
would be interesting, as in Unix:

        p1 | p2

where the processes and communication channels are
anonymous (p1 is the name of the procedure NOT the
process). This kind of notation is much better than
spawning thread individually and passing channel
arguments, since the channels then have to be named,
and may end up being owned by a third thread, preventing
deadlocked threads suiciding.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to