Welcome, Guest. Please login or register.

Author Topic: From low level exception handling to high level...  (Read 9819 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: From low level exception handling to high level...
« Reply #29 from previous page: October 24, 2006, 11:47:42 AM »
Quote

Speelgoedmannetje wrote:

and I have never programmed for the 68k


You are missing out, my friend! M86K assembly is actually fun. I wish I could say the same about PPC or x86, both of which I can manage (PPC moreso than x86) but they always seem to be a bit of a grind.
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: From low level exception handling to high level...
« Reply #30 on: November 05, 2006, 05:34:05 PM »
@Piru
Quote

Piru wrote:
@Karlos

Quote
Do you ever sleep?

I do. Perhaps not at the same time as others. I also like blood, and... Ehh, wait, forget that.


Your terrible secret is out:



(sorry, couldnae resist!)
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: From low level exception handling to high level...
« Reply #31 on: November 07, 2006, 01:00:14 PM »
@Anybody interested

Quote

Piru wrote:
I believe in this case you're lucky to have "close" enough environment in both the code nuking and the catch part. However, I'm pretty confident this isn't always the case.

So I believe to be fully functional in all cases this thing requires some sort of state saving and restoring. For simple cases this could well be enough, however.


I made some extensive tests of the idea. The behaviour is exactly as you would expect from manually checking for the problem and throwing a appropriate exception. The only difference is that you don't actually have to check for condition, thereby removing conditional tests for every case.



There is an impact, as Piru predicted, on things like holding locks etc. However, the impact is exactly the same as if you throw an exception manually from within a piece of code. As with all error handling strategies, anything that can be handled locally obviously should be. By using automatically created and destroyed auxilliaries (see earlier post with the Lockable class example) that handle locking (lock on create, unlock on destruct) within a function, this problem is totally mitigated from C++ side.

An exception can occur deep within the OS, which is a different prospect, but simply restoring the trap within deep implementation of an OS realisation of a class is more than sufficient to handle this case.

So the end result is, for high level code the technique works, and works well. When dealing with much lower level code, which naturally should be restricted only to implementation details, the handling can be safely deactivated to prevent any ill effects from diverting the flow of execution at the point of failure.
int p; // A
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: From low level exception handling to high level...
« Reply #32 on: November 14, 2006, 12:30:41 PM »
One for Piru:

Any way of getting the CPU to trap access to address zero? I am basically assuming this isn't feasable without buggering around with the MMU?

If it is feasable, that's the hardware issued NullPointerException sorted :-)
int p; // A
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: From low level exception handling to high level...
« Reply #33 on: November 14, 2006, 01:11:49 PM »
Quote
Any way of getting the CPU to trap access to address zero? I am basically assuming this isn't feasable without buggering around with the MMU?

Correct, this is not possible without making the first MMU page invalid. Even then, access to bytes 4..7 must remain valid (SysBase load).

Quote
If it is feasable, that's the hardware issued NullPointerException sorted

Actually not quite, it would not catch read accesses that end up between 4..7.

Since this would require per task MMU tables, the only semi-feasible way to do it would be mmu.library.
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: From low level exception handling to high level...
« Reply #34 on: November 14, 2006, 01:28:34 PM »
@Piru

Thanks, that's pretty much what I thought anyway. Shame, mmu.library seems to utterly hate my system :-(
int p; // A