From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <449180D4.60100@comtv.ru> Date: Thu, 15 Jun 2006 19:46:28 +0400 From: Victor Nazarov User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] quantity vs. quality References: <8ccc8ba40606121415i63c1064fi5ae59cf04fca7aa2@mail.gmail.com> <20060614220919.GG7331@submarine> In-Reply-To: <20060614220919.GG7331@submarine> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 6af542a6-ead1-11e9-9d60-3106f5b1d025 Roman Shaposhnick wrote: > Suppose we're deep down in a call stack which looks somewhat like this: > > main > ... > foo > ... > bar() > > now, there's a fixable exception that occurs in bar(), lets say a call > to malloc that return NULL. Also suppose that I do have a strategy > for dealing with OOM conditions, but I don't want it to clutter my > bar() code. In fact, I don't even want it to be local to the process > but rather implemented as a policy on a standalone server. All of that > means that I can't just simply write: > > try { > malloc(); > } catch(...) { > > } > > but I have to transfer the control to the higher authority. I expect > the codition which lead to OOM be fixed at that level, and all I want > to have at the level of bar() is to see my malloc() call be restared. > Automatically. Alternatively the authority could decide that malloc() > has to be terminated at which point my control flow will resume past > the 'malloc();'. > > Now, we have a mechanism for the exception to be propagated upwards > (I can even do it in C with things like waserror()), but there's no > mechanism for the "fix" to be "propagated" downwards and have > my call to malloc be automatically restarted. > > On one hand it shouldn't be too hard to make such a thing part of the > language, but I haven't seen anything like it yet. So are there any > better solutions to the problem I've just described or am I talking > nonsense here ? ;) > > What about creating a Plan9-thread for the error recovery mecanism. This thread would wait for the message on the channel. When we encounter malloc error we send message on the error chanel. Error recovery process error and send message back to us. Getting message we restart malloc... All this require carefull coding, so I didn't try to write an example by myself, but I think it's possible. -- Victor