I want to generate an interrupt while a function is running and then I want the CPU to execute some specific ISR, and after finishing the ISR, the function will resume executing. I am using Windows XP and the MinGW compiler.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A real hardware interrupt will toggle one of the CPU pins and cause it to dispatch to the ISR. I can’t think of any really transparent way to emulate that.
One way to pause the currently-running function might be to use the SuspendThread function, and then use a different thread to run the ISR.
A different possibility to investigate might be to use Fibers.
Edit
As cxxl’s answer suggested, another possibility is to use a real-time priority thread:
Then, whenever you allow the ISR-emulating thread run, it will pre-empt the other thread.