comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Running a background task
Date: Fri, 16 May 2008 08:25:55 -0700 (PDT)
Date: 2008-05-16T08:25:55-07:00	[thread overview]
Message-ID: <c85ae46e-56e0-4e3b-8270-023917d4fe29@l28g2000prd.googlegroups.com> (raw)
In-Reply-To: 62f65249-ace3-44fb-9760-976168856c1e@v26g2000prm.googlegroups.com

On May 15, 5:43 pm, Bender <Jeffrey.S.Morri...@gmail.com> wrote:
> On May 15, 4:31 pm, Adam Beneschan <a...@irvine.com> wrote:
>
> > When Handle_Msg calls on the On_String entry, this starts a
> > rendezvous, and Handle_Msg stops when the rendezvous is done.  Since
> > the "accept" has a "do" part, the rendezvous will not be done until
> > the "do" completes, which in your case never happens.  Thus,
> > Handle_Msg will never proceed past the entry call.
>
> > It's hard for me to give a solution, since I don't know just what
> > you're trying to accomplish; but you may want to move the loop out of
> > the "accept".
>
> >                                  -- Adam
>
> I need to poll the device every 3 seconds.  If I move the loop outside
> of the accept, won't it just call Send_Status_Req procedure one time,
> then finish the task?

No.  If Send_Status_Req is in a loop, then it will call it in a loop.
This is the same whether or not the loop is inside the accept or
outside of it.  The difference is that if it's inside the accept, it
will hold up the task (which could be the main program, technically
the "environment task") calling the entry being accepted, and if it's
not inside the accept, it won't; but other than that, the behavior
will be the same either way.  I'm not clear on why you'd be confused
about this (i.e. why you think it would call Send_Status_Req only
once)---I suspect you may have some misconception about how tasks
work, but I can't think what it might be, so if this is still
confusing to you, you may need to explain a little more clearly what
you're confused about, so that we can help clear up whatever
misunderstanding you may have.


> Surely there must be a mechanism similar to C's pthread that allows me
> to start a thread and let it worry about itself, while the main thread
> continues processing.

That's pretty much what you're doing with tasks.  Ada, however,
doesn't specify whether tasking is implemented with threads or some
other way---that's up to the implementor.  I think threads is a
popular way to implement tasks, though.


>  All I'm seeing here is that the task is run in
> parallel to the other code in the Handle_Msg procedure.

I'm not clear on what the difference is between this sentence and what
you would *like* to happen.


>  I wan't that
> procedure to finish up, and let the rest of the program continue to
> run, all with Poll_For_Status running in the background.

Did you try moving the loop out of the accept?  If so, what happened?
If it didn't work the way you anticipated, then how did it not work?

                                -- Adam




  reply	other threads:[~2008-05-16 15:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 20:51 Running a background task Bender
2008-05-15 22:31 ` Adam Beneschan
2008-05-15 23:14   ` Adam Beneschan
2008-05-16  0:43   ` Bender
2008-05-16 15:25     ` Adam Beneschan [this message]
2008-05-16 15:29       ` Adam Beneschan
2008-05-16  0:16 ` Jeffrey R. Carter
2008-05-16  0:49   ` Bender
2008-05-16  4:32     ` Jeffrey R. Carter
2008-05-16 14:34       ` Bender
replies disabled

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