comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Broadcasting message to OTHER NODES
Date: Fri, 10 Oct 2014 21:15:58 +0300
Date: 2014-10-10T21:15:58+03:00	[thread overview]
Message-ID: <c9qm2eFtarfU1@mid.individual.net> (raw)
In-Reply-To: <5633f27b-ffdd-47f3-a32b-9992d67ff135@googlegroups.com>

On 14-10-10 20:51 , Stribor40 wrote:
> On Friday, 10 October 2014 13:42:58 UTC-4, Niklas Holsti  wrote:
>> On 14-10-10 19:23 , Stribor40 wrote:
>> 
>>> I have 6 nodes and each of those nodes have 2 partners.  So for 
>>> example...
>> 
>>> task myNode is
>>>    entry TurnOff;
>>>    entry LetMeKnow;
>>> end  myNode;
>> 
>>> I am trying to wrap my head around something like this ....so one
>>> of those nodes can send signal to those 2 partners to turn off
>>> the lights and let me know about it which is fine...The problem
>>> is that now those 2 partners also have 2 partners that need to be
>>> let known to turn the lights off and let me know about it.
>> 
>>> Can someone please point me or suggest how to go about this 
>>> please.
>> 
>> Please describe your goals more fully. What is the overall 
>> application or program that you would like to create? What are 
>> these "nodes"? Why do they send signals to each other? What should 
>> be the over-all effect of these signals? Where does the first 
>> signal originate?
> 
> first signal would go from main(which is i guess 7th task). So 
> basically main tasks will call task1 and tell it to turn light off 
> and then if wait at let me know entry.

If the main task (the "environment" task, in Ada terminology)
immediately waits on LetMeKNow, after calling TurnOff, why not have the
main task wait in TurnOff until the "turn off" action is completed?

(Of course this would present all real concurrency between the tasks,
but then I don't understand why this program needs concurrency at all.)

> Now task1 will tell left and 
> right partner to turn lights off and also wait at let me know entry.
>  I am trying implement cascading effect like idea or propagating 
> original turn me on signal that started on main (who is currently 
> waiting at let me know entry) all the way to last node. When I say 
> node i meant that each node is a task itself

That's a little bit clearer, but the reason for using tasks is still
obscure. Also unclear is what your problem is -- what kind of help do
you need?

As I understand it, you have a graph of nodes -- whether it is directed
or undirected is not clear -- and you want to propagate an action or
signal ("turn off") that starts from one point, should reach all nodes
in the graph through the "left partner" and "right parner" links between
nodes, and the originator of the signal should be informed when all
nodes have received the signal.

You don't show how a node knows its partners. Are the nodes numbered in
some way? Or are they used through access variables?

For some elements of a solution, you should read about depth-first
traversal of graphs -- http://en.wikipedia.org/wiki/Depth-first_search.

If the nodes were records instead of tasks, the problem would be simple
to solve by a recursive "traverse" procedure using depth-first search.

If the signal "turn off" can arise more than once, you may have to add
some kind of signal identifier -- for example, the sequential number of
the signal -- to keep track of which signals a node has received, and
which it hasn't.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


  reply	other threads:[~2014-10-10 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 16:23 Broadcasting message to OTHER NODES Stribor40
2014-10-10 17:43 ` Niklas Holsti
2014-10-10 17:51   ` Stribor40
2014-10-10 18:15     ` Niklas Holsti [this message]
2014-10-10 18:33       ` Niklas Holsti
2014-10-10 18:42       ` Stribor40
2014-10-10 19:33         ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox