[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

JCSP - Interpreter (& too restricted visibility of classes in JCSP package)



Dear list members,

The JCSP library is nice. However, for my purposes there is too much
package protected. Is this for some reason? 

I am creating a special CSProcess, let I call it an Interpreter. The
Interpreter is decoupled from the application functionality (e.g. it
does have several processes in an array). The Interpreter may take care
of other non-functional aspects:
      * Scheduling: The ParallelInterpreter does have a run() method
        that calls all its processes in a Parallel construct. Other
        interpreters may implement all kind of pool policies. The
        Interpreter can be called a Pool in this scenario;
      * Coupling: Instead of containing an CSProcess array, the
        interpreter may access a pool where processes swim around. It
        can take one that performs fast of about which it has positive
        experiences;
      * Process manipulation: An Interpreter may consider its processes
        and combine them too one new process, before running it:
        Transforming channels to (variable) assignments within the same
        namespace;

To create an Interpreter I want to have ChannelInput's and
ChannelOutput's that carry CSProcess instances. Let I call them
ChannelProcInput's and ChannelProcOutput's. So, the
One2OneProcChannelImpl should implement ChannelProcInput,
ChannelProcOutput and One2OneProcChannel. The methods to overwrite are
only in() and out(): 
  public ChannelProcInput in() { return this(); }
  public ChannelProcOutput out() { return this(); } //and read, write
Regretfully One2OneChannelImpl is package-protected, so I can't extend
it. Neither can I copy its code, because the method schedule of the
Alternative class is not visible either.

Can the visibility be adapted? Or should I create my adapted jcsp
library? In that case I need at last the source code of the
com.quickstone.jcsp.util library. Thanks in advance!

Kind regards,

Anne

On Tue, 2007-01-02 at 10:38 +0100, Anne van Rossum wrote:
> Dear list members,
> 
> Currently I am playing with the JCSP library. I wrote this code that has
> a Writer that writes values on channelA, an Incrementer that increments
> those values and a Reader that reads them and displays them at the
> console:
> 
> Code:
> public static void main(String[] args) {
>     ChannelFactory channelFactory = new StandardChannelFactory();
>     One2OneChannel channelA = channelFactory.createOne2One();
>     One2OneChannel channelB = channelFactory.createOne2One();
>    
>     Parallel processPool = new Parallel(
>       new CSProcess[] {
>           new Writer(channelA.out()),
>           new Incrementer(channelA.in(), channelB.out()), 
>           new Reader(channelB.in())
>       }
>     );
> 
>     processPool.run();
>   }
> 
> Questions:
> I have the following questions regarding this example:
> * The CSProcesses run parallel, but it is unclear how each process gets
> its processing time. Maybe the Reader gets much more cycles than the
> Writer. Who knows?
> * The CSProcesses may be placed in any order. The Incrementer can not
> read a value from its input channel when it is not available. How is
> this implemented? Is the Incrementer polling channelA? Or send channelA
> an event to the Incrementer?
> * The nomenclature of channel.in() and channel.out() is confusing.
> Channel.out() should be the endpoint of the channel, not the output of
> the component where a channel starts. If a channel is a first-class
> entity, it should be treated like that.
> * The Parallel construct is rigid. Why is it not coupled to some kind of
> "parallel" thread pool (or actually a process pool)? The implementation
> of above gives all processes (supposedly) the same amount of processing
> time in parallel. An "alternative" construct is also allowed. And some
> implementing "priorities". That's it. How can I code other process pools
> with other policies?
> * On rewiring the network the One2OneChannel object has to be replaced
> by an Any2OneChannel object or One2AnyChannel object, etc. How can a
> process removed easily? There is a Parallel.removeProcess method that
> will be executed before a call to run(). The Reader process above reads
> continuously from channelB and never stops. How can I swap the Writer
> for another in that case? Code after processPool.run() will not be
> reached.
> * How many threads are there actually? Has every channel, or every
> "plug" of a channel their own thread? Or only the CSProcess objects?
> 
> Background:
> What do I have in mind? I like to develop large-grain dataflow model
> where the large-grain processes are aggregations of small-grain
> processes (and have a better performance). If such a conversion (from
> small to large-grain processes) can be automated, software will
> automatically adjust to the amount and type of hardware processors
> (multiple CPUs, FPGAs, etc.) 
> For that:
> * Different CSProcesses should be implemented;
> * Those should be swapped for each other easily;
> * Those should be compared w.r.t. performance;
> * Aggregations of CSProcesses should be compared with the distinct
> CSProcesses w.r.t. performance;
> * Channels should be plugged somewhere else easily.
> Etc. etc.
> 
> Thanks a lot in advance for taking time!
> 
> Kind regards,
> 
> Anne
>