Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This is bang-on, and takes me back to writing word processing code in assembler back in the late 70s.

When an interrupt happens, the processor suspends whatever it's doing; it stuffs all of the register values, including the program counter, onto a stack, then calls the appropriate interrupt service routine. When that (very slim) routine is finished, it executes not a normal RET (subroutine return), but an RTI (return from interrupt) which pulls not only the program counter from the stack, but the values of all the registers. Thus, as far as the original code knows, nothing happened (OK, this depends on the processor architecture, but you get the idea).

Even cooler -- while an interrupt is being processed, that level of interrupt and everything below it is disabled, which means any interrupt that happens during the routine is ignored until the RTI is executed. If a higher level interrupt occurs, the obvious happens -- registers are pushed, and the processor again jumps to another interrupt service routine.

So, when an event occurs, you want to have the shortest (fastest) possible interrupt service routine handle the event, so that the processor can get back to whatever it was doing, such as drawing text on the screen, processing keyboard input, or waiting in an idle loop, without dropping any data. The idle loop runs around and waits for things to magically appear in the queues, via the interrupt service routines. It can then do the laborious process of figuring out what complicated processing needs to be done with the keystroke, without the worry that another event is going to come along and perhaps be dropped.

Problems occur when the interrupts come too thick and fast for even the slender interrupt service requests to deal with -- either that of the code that handles the incoming data can't empty the queues fast enough.

Fun stuff, and good to remember in this context.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


In reply to Re^2: How to wait for events, and not lose any, while processing them ? by talexb
in thread How to wait for events, and not lose any, while processing them ? by Eyck

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found