friends..currently working on designing a scheduler in Borland C. I don't have idea how to preempt a function using interrupt with out the function's cooperation.
friends..currently working on designing a scheduler in Borland C. I don't have idea how to preempt a function using interrupt with out the function's cooperation.
What you can and can not do with an interrupt, depends on the OS you have. In DOS days, you had complete access to the interrupts, but you can't do with a multi-tasking OS, it would be chaos and crash city.
It's not a problem for C - C doesn't care what the OS will or won't do with an interrupt request. It just will make it that request, if you add that line of code.
So check with your OS experts for the OS you want to use this on.
As noted by Adak, it all depends on the OS and if you don't have one then you need to DIY by figuring out how to interrupt the micro during the function call.
This would involve saving the current process data on the system stack, servicing the interrupt, and returning to process the function call ie re-entrant.
usually task switching in DOS or roll your own OS's is done using int 15h the timer interrupt.