comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: A common array
Date: Sat, 20 Dec 2003 13:06:30 -0500
Date: 2003-12-20T13:06:30-05:00	[thread overview]
Message-ID: <dtudnfQc_fM6EnmiRVn-ug@comcast.com> (raw)
In-Reply-To: <3fe415d7$1@news.barak.net.il>

First, this looks like a homework assignment.  Doesn't mean you won't 
get help here, just that people are less likely to provide code instead 
of understanding.

Ratson Janiv wrote:

> Thanks I understand that, in my case a cell in the arrray will be updated
> only once.

Don't forget to mark the array in some way so that the elements can be 
separately addressed.  Look at pragma Atomic, and pragma Atomic_Elements 
to decide how you want to address this.

> The other unsolved problem is that I dont know how to reallocate a number to
> a task.
> If I check numbers between 1..100, and I only have 8 tasks, The manager task
> willhave to reuse teh tasks to keep checking the other numbers. hence, a
> manager should reallocate a new number to a task that has finished checking
> the previous number.
> I though about a notification mechanism, hence, each check task will notify
> the manager task that it finished checking, and the manager task will
> reallocate a new number to that task. My problem is that I do not know how
> the Manager Task will know which task has notified it.
> Any ideas how to solve this problem ? M I in the right though about
> notification, or there is a better way ?

There are several ways to do this. First you can have a task (or tasks) 
that hands out numbers to be checked during a rendezvous.  Second you 
can have a protected object, or objects that hand out numbers to be 
checked.  In other words the protected object would contain a procedure
that returns a new value to check as an out parameter.  You can have the 
value returned by a function in the protected object, but this is 
tricky.  If you can figure it out, you will see that the actual function 
called need not be protected at all.

Finally you can pass each task a set of numbers to check when it is 
created.  This is a much more efficient solution since it allows you to 
minimize the interactions between tasks.  If I was writing this, this is 
the way I would go.  Further, I would have the task provide results in 
batches--IF that made things faster.  It may not, that will depend on 
the compiler you use, the hardware architecture, and other decisions you 
make in your program design.

-- 
                                           Robert I. Eachus

"The war on terror is a different kind of war, waged capture by capture, 
cell by cell, and victory by victory. Our security is assured by our 
perseverance and by our sure belief in the success of liberty." -- 
George W. Bush




  reply	other threads:[~2003-12-20 18:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-17 22:08 A common array Ratson Janiv
2003-12-18  2:25 ` Stephen Leake
2003-12-18  3:10   ` Wes Groleau
2003-12-19 15:13     ` Mr. J.
2003-12-20  3:23       ` Wes Groleau
2003-12-19 15:10 ` Ratson Janiv
2003-12-20  9:24 ` Ratson Janiv
2003-12-20 18:06   ` Robert I. Eachus [this message]
2003-12-20 18:56 ` @Fill(NOSPAM)YourBrain.com
replies disabled

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