Loading ...
Sorry, an error occurred while loading the content.
 

RE: [jallist] Interrupt safe routines ?

Expand Messages
  • Wouter van Ooijen
    (solving re-entrancy problems with interrupts) 1. block all interrupts in procedures 2. if procedures are used in interrupts, make a wrapper that saves all
    Message 1 of 5 , Feb 1, 2003
      (solving re-entrancy problems with interrupts)

      1. block all interrupts in procedures
      2. if procedures are used in interrupts, make a wrapper that saves all
      local registers
      3. make 2 copies of each routines, one for interrupts, one for
      main-thread

      1 is not useable, the main loop might be in a procedure, and it would
      cause unpredictable interrupt latency.

      I think 3 is the better solution, even though it can generate more code.

      issues:
      - 18F's have 2 interrupts
      - when a procedure uses a global variable, should it be separate for the
      interrupt and main code copies or shared? I think both must be
      available.

      BTW cloning a procedure might also be handy for certain optimizations,
      and for stack entry elimination.
      Wouter van Ooijen

      -- -------------------------------------------
      Van Ooijen Technische Informatica: www.voti.nl
      consultancy, development, PICmicro products





      [Non-text portions of this message have been removed]
    • Vasile Surducan
      ... I m sorry but I don t understand this point: block al interrupts ... This seems to be correct. ... This may be correct to, but have some curious sense
      Message 2 of 5 , Feb 2, 2003
        On Fri, 31 Jan 2003, Stef wrote:

        > 1. block all interrupts in procedures
        > 2. if procedures are used in interrupts, make a wrapper that saves all
        > local registers
        > 3. make 2 copies of each routines, one for interrupts, one for main-thread
        >
        > ad 1.
        > ======
        > This seems not a good solution to me, because you loose the main power
        > of an interrupt: "asynchronuous"

        I'm sorry but I don't understand this point: "block al interrupts"


        >
        >
        > ad 2. here an example of what I had in mind
        > ===================================
        > <JAL>
        > procedure TEST is
        > --- here is the nomal functionality
        > end procedure
        >
        > -- assume the procedure TEST uses 2 local variables x,y
        > -- then the procedure to be used in the interrupt should save and
        > restore these
        > procedure TEST_INT is
        > x_save = x
        > y_save = y
        > TEST
        > y = y_save
        > x = x_save
        > end procedure
        > </JAL>
        >

        This seems to be correct.


        >
        > ad 3. here an example of what I had in mind
        > ===================================
        > <JAL>
        > -- so here is the normal procedure
        > procedure TEST is
        > --- here is the nomal functionality
        > end procedure
        >
        > -- and here and exact copy (with different local variables) to be
        > used in interrupts
        > procedure TEST_INT is
        > --- here is the nomal functionality
        > end procedure
        > </JAL>
        >

        This may be correct to, but have some curious sense for me.

        >
        > So my questions:
        > - are there any other solutions ?

        the best one is to use only assembler and only inline. At least this
        methode never gaves me headache. Calling other jal routines or assembler
        routines from isr *always* was with problems.


        > - which is the best solution ( In general, I think solution-2 will use
        > less codespace while solution-3 uses less computation time)

        I think there is no best solution. For slow events, saving flag in
        interrupts and use the flags in main it works perfect. For faster events,
        just treat the event in assembler inside the isr. For very fast events I
        don't know...


        > - will this problem be solved for the implicit JAL routines ?
        >
        what is an implicit jal routines ?

        best, Vasile
      • Stef
        ... procedure do_something is disable_interrupts ...do all your functiobal stuff enable_interupts end procedure ... hardware ? ... And some
        Message 3 of 5 , Feb 3, 2003
          >
          >
          > I'm sorry but I don't understand this point: "block al interrupts"
          >
          >
          <JAL>
          procedure do_something is
          disable_interrupts
          ...do all your functiobal stuff
          enable_interupts
          end procedure
          </JAL>

          >the best one is to use only assembler and only inline. At least this
          >methode never gaves me headache. Calling other jal routines or assembler
          >routines from isr *always* was with problems.
          >
          >
          >>- which is the best solution ( In general, I think solution-2 will use
          >>less codespace while solution-3 uses less computation time)
          >>
          >>
          >I think there is no best solution. For slow events, saving flag in
          >interrupts and use the flags in main it works perfect. For faster events,
          >just treat the event in assembler inside the isr. For very fast events I
          >don't know...
          >
          >
          hardware ?

          >>- will this problem be solved for the implicit JAL routines ?
          >>
          >>
          >>
          >what is an implicit jal routines ?
          >
          And some innocent looking operators like *, %, /, << and >> (shifts by
          more than 1) are implementated as procedures/functions....

          Stef


          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.