Sign in to follow this  

Adverse effects on reserving services from OS?

This topic is 2662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets assume we have an exception handler that catches is supposed to report catch and report unsolvable errors that tickle from other handlers down the exception handling hierarchy.

For comprehensive error report, a textfile would be optimal. It would make sense to request handle to your own "Error.txt" file whenever such unwanted scenario would occur.

Im wondering if there is a sitatuon where requesting filehandle from the OS would be impossible due to the nature of exception currently handled ( bad_alloc or similar? ).

And would requesting the filehandle during initialization of the application solve this possible problem?

Is there a downside in doing this, apart from reserving a open file slot from the OS, even when such service is not immediately needed by the app and potentially never will be?

Opinions?
Thoughts?

Programming language used is not really relevant for the question, but C++ and Win32 would be the environment I am coming from with the dillemma...


// Typos are dime a dozen. Fixing em as I go.
// This is embarrasing... Should pay more attention to spelling...
// Once more, sorry for typos. I have been up a bit too long.

[Edited by - rmed002 on August 31, 2010 7:07:11 AM]

Share this post


Link to post
Share on other sites
"Service"? OS service?

Quote:
sitatuon where requesting filehandle from the OS would be impossible

Yes, when system runs out of handles which, among other reasons, occurs when OS runs out of memory. It's easy to test - use a virtual machine, set its RAM to something very low (I managed to boot XP with 64MB of RAM), then start an app or two. Some will be missing various parts, such as icons or menus, others won't even start.


The theory behind this type of error handling is complicated and depends on internals of various OSes.

General rule is - general exception handlers must not allocate resources of any kind. In practice, allocating all resources used by such handlers at start is sufficient.

It is likely not enough when trying to do IO. Opening a file might work, but considering complexities of file systems, each write request might do a ton of magic behind scenes (journaling, transactional NTFS, ACL verification, compression, encryption, ...). If OS runs out of memory, some or all of those are quite likely to fail. So even though handle is valid, writes might not be possible.

It all comes back to abstractions. This type of failure isn't all that relevant, so it's not solved in any particular way in most systems. For systems which actually require such guarantees (legal or similar reasons), everything supports it - having an unhandled exception would be considered a failed audit.

So allocating all resources upfront is a reasonable option that avoids some, but not all issues. The other alternative is to properly handle all error conditions. In practice it doesn't matter all that much.

Quote:
Is there a downside in doing this, apart from reserving a open file slot from the OS, even when such service is not immediately needed by the app and potentially never will be?

My printer drivers are freeking 370MB. So HP doesn't seem to have a problem reserving a resource. Or 300 million of them.

Share this post


Link to post
Share on other sites

This topic is 2662 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this