From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Running a background task
Date: Fri, 16 May 2008 04:32:47 GMT
Date: 2008-05-16T04:32:47+00:00 [thread overview]
Message-ID: <P78Xj.165826$yE1.60240@attbi_s21> (raw)
In-Reply-To: <a296dff1-13bf-4591-b399-ae68dd88f780@u6g2000prc.googlegroups.com>
Bender wrote:
>
> That's my question in a nutshell. I need the task to run forever. I
> need the Handle_Msg procedure to end and start handling other incoming
> messages.
There are at least 2 tasks in your code: Status_Task and the task that calls
Handle_Msg. In Ada, all execution is part of a task; a purely sequential program
(without any explicit tasks) is the execution of an implicit task called the
environment task.
So "the task" is ambiguous, but I presume you mean Status_Task. As written,
Status_Task does run forever. It's the other task that's blocked.
> Will this solve my problem? Unfortunately I'm at home at the moment,
> but once I get into work I'll give it a shot. Once the 'end
> On_String' is reached, will Handle_Msg continue on, while the task
> continues to run?
Yes, IIUC. When the rendezvous ends, at "end On_String", both tasks continue
(conceptually) in parallel. Handle_Msg will continue with the next statement
after the call to Status_Task.On_String, and the Status_Task will continue into
the loop. I think this is what Beneschan meant by 'move the loop out of the
"accept"'.
If you have fewer tasks than processors, it's possible to write code such that a
task that is ready to run never executes ("starvation"), but that's probably not
something that you need to worry about.
--
Jeff Carter
"Many times we're given rhymes that are quite unsingable."
Monty Python and the Holy Grail
57
next prev parent reply other threads:[~2008-05-16 4:32 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
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 [this message]
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