why this code is true??

Pages: 12
First, there's no guarantee that the CPU isn't running in real mode, or that the OS will act on the exception and do something.
Second, there's no guarantee what type of CPU it is (x86? ARM? SPARC? Software?).
Third, what the CPU does is ultimately irrelevant to the discussion. We're working one level above it.
there's no guarantee that the CPU isn't running in real mode

True; but if the CPU were running in real mode then you'd have to deal with that yourself.

[there's no guarantee] that the OS will act on the exception and do something

Well it's pretty much impossible to get to user mode without an IDT; so I find it hard to believe that the OS wouldn't have a handler registered for int 13... If you didn't have an IDT and you ran a usermode program you wouldn't be able to get back to ring 0, so you'd have a pretty worthless OS. At any rate, I said "probably" kills your process, so it doesn't matter.

Also, if you DID cause int 0x0D and the OS had no handler for that interrupt, then that would cause a double fault. If the OS had no general protection fault handler, then it probably wouldn't have a double fault handler, either. The CPU would then fault trying to find the double fault handler, and that would cause a triple fault. So then the CPU would SHUTDOWN and the motherboard would probably reset the computer.

Second, there's no guarantee what type of CPU it is (x86? ARM? SPARC? Software?).

x86 was assumed because that's what the vast majority of computer users have. Besides that, I'm fairly sure ARM, SPARC and PPC use interrupts (or something similar) as well. I don't see how a CPU could operate without them.

Third, what the CPU does is ultimately irrelevant to the discussion. We're working one level above it.

You asked what would happen if you tried to access *p "no matter what" p was pointing to.
Well it's pretty much impossible to get to user [...]
None of that matters.

I don't see how a CPU could operate without them.
How unimaginative.

You asked what would happen if you tried to access *p "no matter what" p was pointing to.
No. I asked
is the statement *p; supposed to use the memory pointed to by p no matter what [...]?
If the behavior is undefined, then there's no answer. "Such and such happens in this or that processor" is not an answer, because at this level the specific of the processor don't concern us. I could write a virtual processor that made demons fly out of your nose before going and allocating more space in your physical file system to use as main memory every time you tried to access memory that doesn't exist. The behavior there is also defined at the processor level, but that doesn't change the fact that from the perspective of a C/++ programmer, it's unknown what's going to happen, because the language's standard didn't define any behavior that the compiler should implement.
How unimaginative

:(

I can be imaginative, in the right mood. I suppose you could have a buffer of sorts to store "requests." Every now-and-again the CPU checks the buffer for a request and if there is one, it deals with it. But I think constantly polling a cache of requests would be expensive, and interrupts are probably a better mechanism. I can be very... inventive at times. Like the time I said we should build a ring of solar panels around a star (not the Sun) that completely cover it and draw all of it's power output. But I digress...

If the behavior is undefined, then there's no answer. "Such and such happens in this or that processor" is not an answer, because at this level the specific of the processor don't concern us. I could write a virtual processor that made demons fly out of your nose before going and allocating more space in your physical file system to use as main memory every time you tried to access memory that doesn't exist. The behavior there is also defined at the processor level, but that doesn't change the fact that from the perspective of a C/++ programmer, it's unknown what's going to happen, because the language's standard didn't define any behavior that the compiler should implement.

I didn't see that. I thought you were just asking what would happen as a rhetorical question (i.e. one you already know the answer to).
Ah, crap. Here we go derailing, again.
A ring wouldn't completely cover a star. You'd need a sphere. Also, both such structures already have names. They're called Dyson sphere and Dyson ring. There's also a Dyson bubble, which is a sparser Dyson sphere.
I accept no blame... not this time, anyway. I said "But I digress" meaning "ignore what I just said because it's off-topic."

A ring wouldn't completely cover a star. You'd need a sphere

Oh yeah.

Also, both such structures already have names. They're called Dyson sphere and Dyson ring.

Interesting. Well, now they're a Chrisname sphere and Chrisname ring because I came up with them before I knew they already existed. That means I invented them, right?

Edit: wait, do you mean like the vacuum cleaner? http://www.knewlove.com/blog/wp-content/uploads/2008/04/dyson%20ball.jpg

Edit:
A Dyson sphere is a hypothetical megastructure originally described by Freeman Dyson. Such a "sphere" would be a system of orbiting solar power satellites meant to completely encompass a star and capture most or all of its energy output.

He copied me!
Last edited on
Wasn't there an episode of Star Trek TNG or something that had a Dyson sphere?

EDIT:

Yep. Now I feel nerdy for remembering that:

http://www.daviddarling.info/encyclopedia/D/Dysonsp.html
Last edited on
Topic archived. No new replies allowed.
Pages: 12