Re: Stopping execution
- From: "Victor Bazarov" <v.Abazarov@xxxxxxxxxxxx>
- Date: Thu, 26 Apr 2007 16:13:53 -0400
GeorgeJ wrote:
A long long time ago (don't ask) when I was a hobbiest in the "dark
ages" of the 8 bit 8085, I understood something about interrupts. I
know very little about how modern microprocessors work.
I am not sure much has changed. Pressing some key on a keyboard is
still a hardware interrupt that the OS has to respond to in some kind
of "driver". That driver tells the OS that a hardware event has
occurred, and the OS then forms some other kind of information which
it forwards to the active process(es).
To what
extent (if any) does the fact that "the execution environment traps a
certain system event" slow down the acutal execution of a bit of code
I might write?
I don't believe that you should concern yourself with any potential
slowdown due to the OS' kernel having to do something.
Or, to expand on this question, suppose I come up
with a doozie of a number-crunching routine in C++ which I predict
will take hours to run. Is there any way to tell the system "just
concentrate on this till I get back from lunch.
It will, without your special instruction, I believe.
If someone comes to
the computer and starts moving the mouse around for example, ignore
it. The only thing from the external world I want you to recognize
is Ctrl-C in case I decide to stop the program when I get back."
The OS cannot ignore it -- it's a multiprocess OS, other processes
may need to respond to mouse movement, and the sheer presence of
other processes does have a toll, but it's not significant by any
measure.
I
guess what I'm asking amounts to "Is the processor spending time
jumping back and forth between running my program and doing general
system checks, and possibly running some other programs at the same
time?"
Yes, it does.
If so, is there any way to modify this?
Yes, you can jack up the priority of your process. You can even
raise it above the kernel (probably), which can suspend all hardware
servicing, which is probably not a very GOOD IDEA(tm).
In most cases such modification will allow you to save a few seconds
over a multi-hour run of your program. Is it really worth your time
to try to implement some kind of "disable-the-kernel" gizmo?
How do experienced
programmers who want absolute top speed for execution of algorithms
deal with this situation?
They mostly rely on the OS' capability to "do it the right way".
I realize this is a complex, open-ended question necessarily so due
to my state of ignorance about what is actually going on under the
hood :).
In most cases "don't worry, be happy!" is what you need to adopt as
your slogan.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.
- References:
- Re: Stopping execution
- From: Victor Bazarov
- Re: Stopping execution
- Prev by Date: Re: Stopping execution
- Next by Date: Re: Stopping execution
- Previous by thread: Re: Stopping execution
- Next by thread: Re: Stopping execution
- Index(es):
Relevant Pages
|