Fwd (andre@merzky.net): Re: [saga-rg] context problem
[[ just putting the thread back onto the list before answering ]]
Thilo
----- Forwarded message from Andre Merzky
Date: Fri, 14 Jul 2006 19:53:07 +0200 From: Andre Merzky
To: Thilo Kielmann Cc: Andre Merzky Subject: Re: [saga-rg] context problem The problem is not really C++ here I think. The code snippet below is semantically challenging in any language, and we need to define that semantic in the spec.
The implementation in C++ is another issue, and simple :-)
Making a copy of the context does not help. The problem, as said, is that the 'remove_context' can get called before or while that context is used, and that needs to have a well defined semantic in the (lang independent) spec.
Having it a user level error is an option. Well, not really an error, but what you say (I think) is that the later operations on that object cannot use the Globus context - right?
Cheers, Andre.
Quoting [Thilo Kielmann] (Jul 14 2006):
Hi,
I think this issue "nicely" confuses SAGA semantics and C++ memory management.
From a SAGA viewpoint I would say: it is an error (mistake by the user) to remove a context from a session if this context is still to be used, e.g. with the task object in the example.
Issues with C++ objects going out of scope when they are still needed have to be resolved within a C++ language binding. for example: s.add_context(c) could make a copy of the c object. Or: the add_context operation prescribes that the c object it got will not be destroyed elsewhere (and then the desctructor of s is in charge of freeing this memory)
Having "remove context advisory" solves neither problem. As appliation programmer, I would be confused...
Thilo
On Fri, Jul 14, 2006 at 04:46:33PM +0200, Andre Merzky wrote:
Date: Fri, 14 Jul 2006 16:46:33 +0200 From: Andre Merzky
To: SAGA RG Subject: [saga-rg] context problem Hi folx,
I realised that we are running into some problems with our current session and context handling. For example:
------------------------------------------------------------ saga::task t; saga::session s;
{ saga::context c (saga::context::GSI);
s.add_context (c);
saga::file f (s, url);
t = f.copy saga::task::Task (target);
s.remove_context (c); } // as it leaves the scope, the gsi context gets destroyed.
t.run (); // the task can not use the GSI context, although the file // object and the copy task have been created in a session // with a valid GSI context. ------------------------------------------------------------
The problem really is that, as a context gets removed, no assumption is made about the fact that the session might have active objects which are currently using that context.
The example above is harmless - image a context getting removed between two subsequent read calls, or while a task is _running_.
I would propose to change the semantics of remove_context to be advisory, i.e. to allow existing objects and tasks to continue to use the context if (and only if) it was already used by them before. The session SHOULD free context related resources as soon as no object uses it anymore. list_context() MUST NOT list the removed context anymore.
We have similar mechanisms in place to keep sessions alive if they are needed by objects, and to keep objects alive if they are needed by tasks. So that would be a somewhat coherent approach.
The downside of course is that, at one more place, resource deallocation is out of sync with the appearent object destruction.
Any opinion?
Cheers, Andre.
-- "So much time, so little to do..." -- Garfield
-- "So much time, so little to do..." -- Garfield
----- End forwarded message ----- -- Thilo Kielmann http://www.cs.vu.nl/~kielmann/
From: Andre Merzky
To: Thilo Kielmann Cc: Andre Merzky Subject: Re: [saga-rg] context problem
[[ flipping the order of Andre's remarks ]]
Making a copy of the context does not help. The problem, as said, is that the 'remove_context' can get called before or while that context is used, and that needs to have a well defined semantic in the (lang independent) spec.
Having it a user level error is an option. Well, not really an error, but what you say (I think) is that the later operations on that object cannot use the Globus context - right?
Right, we agree. If there are more/other contexts that might still be OK. IMHO, if the programmer is removing a context that is still needed, that is a mistake that might lead to an error.
The problem is not really C++ here I think. The code snippet below is semantically challenging in any language, and we need to define that semantic in the spec.
The implementation in C++ is another issue, and simple :-)
The "problem" was that your mail was intertwining both aspects. Sure, the can be a simple setup in the C++ bindings, once the SAGA semantics are clear... Cheers, Thilo -- Thilo Kielmann http://www.cs.vu.nl/~kielmann/
Sorry that I took the thread off the list - not my intention... Quoting [Thilo Kielmann] (Jul 15 2006):
Making a copy of the context does not help. The problem, as said, is that the 'remove_context' can get called before or while that context is used, and that needs to have a well defined semantic in the (lang independent) spec.
Having it a user level error is an option. Well, not really an error, but what you say (I think) is that the later operations on that object cannot use the Globus context - right?
Right, we agree. If there are more/other contexts that might still be OK. IMHO, if the programmer is removing a context that is still needed, that is a mistake that might lead to an error.
Yes, we could do that, agree. However, we are already going a different route with sessions and tasks: -------------------------------------------------------- saga::task t; { saga::session s; saga::file f (s, url); t = f.copy saga::task::Task (target); } t.run (); // session and file object are gone here - however, the // task still lives, and keeps the session and object // resources alive. At least some state must be // maintained internally -------------------------------------------------------- As usual, that example is in C++, but the problem is independent of the language. I think that this is the same problem really as with the context. I think we should solve the the same way. The problem really is, I think, that the above example is the dominating one. Tasks, as they represent async ops, are bound to get passed around through different scopes, and it would be burdensome to expect the programmer to keep all associated objects, sessions and contexts etc. alive. Well, thats IMHO at least - what do you think? Cheers, Andre. -- "So much time, so little to do..." -- Garfield
participants (2)
-
Andre Merzky
-
Thilo Kielmann