From: John Morrison (jmorrison_at_ahc.net.au)
Date: 2002-04-02 14:32:38
<<<< This was written today before Jim Posted his reply but I didn't want to
wast all that typing >>>>
<<<< Wrote this on my 2 hours train travel to work.......I love my Laptop
:-) >>>>
Been having a little thinking over the Easter break and thought I’d run this
hybrid idea (based on Jims original idea) past the general population.
Assumptions/Constraints
First thing Context switching is a pain and chews up processing time but in
some cases is required. :-(
The original “1 thread” proposed has the major disadvantage that if any
component gets into an endless loop or in some way locks up whole program
stops. So I think we should have a thread for the user interaction so that
if something does lockup at least the user can click “Exit”. Also there
WILL be ”User interface” modules that require constant updates even when
there is no real data. Eg MP3 player, animations, Setting up and closing
down the network.
On the other end of things I’m concerned about the I/O being lumped in with
the processing and the possibility of loosing data (How long does a byte
stay valid from an i/o device?). So I think that a thread should be
allocated to the “Device” section.
Network of Nodes
I’m a little worried about buffering only 1 character/block at a time it
was perfectly fine with just one thread BUT as I’ve said above we “may”
loose data and have lockups you can’t escape from. So I propose a circular
buffer with the size specified by the next stage(s) this also gives us a
rewind capability for the next stage without instituting new code.
Proposal
3 threads
- Device
- Processing
- User interaction
Each of these threads would be handled by the “network of nodes” system.
Node Class
Each node within the system has to contain a “Node” object that is used as
the interface between modules.
ModuleA -> Node1 ---> ModuleB -----> Node2---> ModuleC -> Node3
\-----(Node 1 to
ModuleC)----/
Setup (for above network)
Instantiate ModuleA
Instantiate ModuleB
Instantiate ModuleC
Instantiate Node1
Instantiate Node2
Instantiate Node3
ModuleA.outputNode(referance to Node1)
ModuleB.outputNode(referance to Node2)
ModuleC.outputNode(referance to Node3)
ModuleB.addInputNode(referance to Node1)
ModuleC.addInputNode(referance to Node1)
ModuleC.addInputNode(referance to Node2)
Operation by networkMain object(for above network)
// Check if new data exists
If Node1.newData()
Node1.resetDataFlag() (Is set when new data written)
ModuleA.process()
ModuleB.process()
ModuleC.process()
(Must be done after ModuleB has finished)
Contents of Process
FOR EACH node in InputVector
If Node.newData()
Node.getElement(CurrentCount_ForThisNode);
//
// Do some processing //
//
CurrentCount = (CurrentCount+1) % MaxCount
Each Node is fully controlled by the modules connected to it
(NO autonomous action).
Each Node represents 1 stream of data.
Each Node has only 1 input Module but can have more than one output
Module(eg node1 above).
Scanning is only done on the first node in any path, which allows for
multiple threads.
There is no need for a source module to keep track of destination nodes,
as the destination will collect data.
Temporary bottlenecks handled with ease by buffers.
Anyway that it’s for now I’ve got lots more to go but no time.
Any suggestions on weather this will or won’t work???
John
This archive was generated by hypermail 2.1.4 : 2002-07-27 12:28:43 BST