suspend and resume

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xiajing0228
    New Member
    • Sep 2006
    • 2

    suspend and resume

    I am working on a program that has one function running, then interrupted by another function. After the interrupting function finishes, the original function should resume from the point where it gets interrupted.
    How should i deal with this case?
    I really appreciate it if someone can give me some suggestions to help a newbie out?
  • D_C
    Contributor
    • Jun 2006
    • 293

    #2
    In assembly, there is a convenient instruction, usually named RETI, that is "return from interrupt".

    How do you plan on generating the interrupt? I assume it's timer- or thread-generated interrupt. Otherwise, I don't see how it wouldn't happen at the same point in your code every time. In that case, you could call a subroutine. If you have the technology to generate interrupts, you should have the technology to return from interrupts.

    Comment

    • xiajing0228
      New Member
      • Sep 2006
      • 2

      #3
      I want to use thread-generated interrupt.pleas e tell me what should i do?Thank you!

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        You don't need to do anything, just start your 2 threads, the OS should handle swopping between them for you.

        If there are sections of code that need to run exclusively (i.e. while 1 thread is running them the other thread can not be allowed to also run them) then use semaphore (or mutex or critical section on windows) prtection to prevent more than 1 thread at a time running the code.

        Comment

        Working...