comp.lang.ada
 help / color / mirror / Atom feed
From: "chris.danx" <spamoff.danx@ntlworld.com>
Subject: Re: multitasking: finishing execution
Date: Thu, 20 Jun 2002 17:19:31 +0100
Date: 2002-06-20T17:19:31+01:00	[thread overview]
Message-ID: <PgnQ8.19178$AZ6.2552769@news6-win.server.ntlworld.com> (raw)
In-Reply-To: 3D11CF27.90401@uk.thalesgroup.com


"Nige" <nigel.scott@uk.thalesgroup.com> wrote in message
news:3D11CF27.90401@uk.thalesgroup.com...

> select
>     accept Finish;
> else
>     -- do code
>     ....
> end select;
>
> will only process the accept if there is an outstanding call to it.

If a handler calls Finish will it wait indefinitely for the task to accept
it?  That was the original question, although in retrospect the first post
was just confusing.


The problem involves a window and two tasks, a watcher and a builder.  A
watcher scans the keyboard, placing any keypresses corresponding to commands
into a protected object, unless Finish is called at which point the watcher
terminates.  The builder retrieves a keypress from the protected object and
does some processing with it until it recieves a call to Finish, when it
terminates.

Upon creation of the window, a handler 'on_create' starts both tasks.  When
the user quits the application (more precisely closes a window, which in
this case happens to be the main window) the on_destroy handler terminates
the task.

My concern is what would happen if the call to the Finish was not accepted
before any time limit expired.  Cohen states that a task must finish
execution before a program can terminate (which makes sense), if the call
wasn't accepted and subsequenctly abandoned the program would fail to
terminate.

If the builder processes information too quickly, any animation will be done
and over with before the user realises it (also if the redraw method is
called continuously it will crash the system, which happened when I forgot
to clear the flag which records if a keypress is available).  To alleviate
this problem a delay alternative has been added to the code, which waits
around 20ms before doing any processing.  (A better solution might be to use
a protected object describing the state and another task which translates
this and draws it to the screen, but this is just practise with tasks and
gwindows before the main project).

If a call to an entry is placed after the delay alternative expires will the
entry succeed (be accepted by the task) in the next iteration (assuming the
next iteration is free to proceed)?  I think it will since entries queue,
but just want to make sure.


Thanks,
Chris






  reply	other threads:[~2002-06-20 16:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-20  9:57 multitasking: finishing execution chris.danx
2002-06-20 12:48 ` Nige
2002-06-20 16:19   ` chris.danx [this message]
2002-06-20 20:40     ` Stephen Leake
2002-06-20 14:53 ` Stephen Leake
2002-06-20 19:30   ` chris.danx
2002-06-21 18:14     ` Ted Dennison
replies disabled

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