Restarting an ISR in a transaction-like style

This is a discussion on Restarting an ISR in a transaction-like style within the Linux Programming forums, part of the Platform Specific Boards category; I am trying to implement restarting of an ISR from the beginning when it is interrupted by a higher priority ...

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Restarting an ISR in a transaction-like style

    I am trying to implement restarting of an ISR from the beginning when it is interrupted by a higher priority handler (in Linux on an x86). To do so, I would like to set (while in the ISR) the instruction pointer (EIP) and offset (XCS) registers to point to the ISR so that it is restarted when it executes RET (It is ok to throw away the ISR's work). What is the best way to do this without erasing information about any handler that the IST itself has interrupted?

    Code:
     
               /* regs is a pointer to registers saved when the interrupt occured */
    void ISR(int irq, void *dev_id, struct pt_regs *regs)
    {
    /* do stuff here */
    
    /* disable all interrupts */
    if (was_interrupted) {
      long eip_;
      int xcs_;
      /* find where void ISR(...) is in memory (segment and offset) 
         and set registers on the stack */
      regs->eip = ?  /* BAD: this will rewrite saved data on the stack */
      regs->xcs = ?
                     /* perhaps jump to ISR? */
      }
    /* enable all interrupts */
    
    }
    Thank you.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    > (It is ok to throw away the ISR's work).
    Exactly how much work are you planning to do?
    ISR's should be short-lived, get in get out, minimal amount of work necessary, without blocking on any resource kind of thing.

    How about
    Code:
    volatile int interrupted;
    void ISR(int irq, void *dev_id, struct pt_regs *regs)
    {
      do {
        interrupted = 0;
        // your work here
      } while ( interrupted );
    }
    Moved to Linux board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    > Exactly how much work are you planning to do?
    I am configuring a device and getting some data in a buffer. I want this to be atomic in the sense that I can be interrupted, and if I am, the higher level handler should run, but then I should restart my copying from the beginning.

    Your code is a good approximation, but it will continue to run the remaining work and THEN restart. Could I avoid this by, say, immediately jumping to ISR again after the ISR knows it has been interrupted.

    Code:
    volatile int interrupted;
    void ISR(int irq, void *dev_id, struct pt_regs *regs)
    {
      do {
        interrupted = 0;
        // your work here
      } while ( interrupted );
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Problem with file
    By nevrax in forum C Programming
    Replies: 12
    Last Post: 04-23-2007, 06:18 PM
  3. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21