Re: Stopping execution

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: [PATCH] xen: core dom0 support
    ... Despite all the noise made about kvm in kernel circles, ... For example, Xen manages to use new hardware virtualization features pretty quickly, partly because it doesn't need to trade-off against normal kernel functions. ... We end up mapping the event channels back to irqs and they are delivered as normal interrupts as far as the rest of the kernel is concerned. ...
    (Linux-Kernel)
  • Re: Embedded Linux Vs. Real time Linux
    ... this is correct (maybe depending on the CPU architecture). ... You need to inspect the Kernel sources to be sure. ... pending when the interrupts are reenabled by the kernel? ... If you do this with an FPGA, maybe the hardware can be done/changed appropriately. ...
    (comp.os.linux.embedded)
  • hardware interrupt mechanism
    ... hardware shares IRQ 11 with other hardwares in the system. ... kernel for device W, can device generate interrupt? ... generate interrupts but there is not suitable interrupt registered yet. ... interrupt handler for itself or not. ...
    (comp.os.linux.development.system)
  • Re: Interrupts in user space?
    ... > kernel space that can receive the interrupts? ... Only the kernel. ... > drivers) somehow pass the interrupt onto the user space application? ... But clever hardware and software design would mean a few lost ...
    (comp.os.linux.development.system)
  • Re: timing code in 2.6.1
    ... The hardware doesn't produce an interrupt ... For medical equipment which affects patient safety, ... These will produce interrupts. ... very likely that you need accurate and consistent time intervals ...
    (Linux-Kernel)