public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
* Task.isDestroyed removed
@ 2007-05-14 16:22 Andrew Cagney
  0 siblings, 0 replies; only message in thread
From: Andrew Cagney @ 2007-05-14 16:22 UTC (permalink / raw)
  To: frysk

FYI,

I've removed the method:
    boolean frysk.proc.Task.isDestroyed()
Re-running the test-suite showed no regressions, but looking at the code 
leaves me wondering if the callers - frysk.rt.SteppingEngine and 
frysk.proc.ProcBlockAction - have a latent race so I'll explain the issue.

The underlying problem here is the race between adding an observer to a 
task, and having that task die.

First lets examine the two most common cases - where things work.  For 
the first:

-> a task dies and is removed
-> client gets Proc's Task list - contains no dead tasks
-> client adds observer to all Tasks

there is no race as the client doesn't even see the dead Task.  
Similarly, if the task dies after the client's observers have been added:

-> client gets Proc's Task list - contains no dead tasks
-> clent adds observers to all Tasks
-> Task dies and is destroyed, client notified via its installed 
termination observer

there is again no race as the observers have been successfully added; 
and presumably the client is now tracking task destruction using the 
termination observer notification.

That just leaves the race, which is being worked around using the sequence:

-> client gets Proc's Tasks
-> Task is destroyed
-> client checks !Task.isDestroyed()
-> client adds observers to Task

but this also fails vis:

-> client gets Proc's Tasks
-> client checks !Task.isDestroyed()
-> Task is destroyed
-> client adds observers to [dead] Task

The correct way to handle this is to instead always send the request to 
the core:

-> client get's Proc's Tasks
-> client adds observers to Tasks
-> core notifies client of success/fail allowing client to prune list 
using methods:
    .addFailed(...)
    .addedTo(...)
Since the core serializes events and requests, it correctly resolves 
these races.

Andrew



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-05-14 16:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-14 16:22 Task.isDestroyed removed Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).