Forum Discussion
Altera_Forum
Honored Contributor
15 years agoIn order to block a process (or similar) you need a scheduler that will spin waiting for some process to be runnable and then switch the stack pointer (and caller saved registers) to that of a the new process and then return back (restoring the rest of the the registers on the way) to where the new process blocked.
This is all hard and complicated and requires enough memory for a stack for each process. With multiple cpus it is even more complicated, since you need to do IPIs (inter processor interrupts) at various times to force the other cpu to perform some actions (with MMus and TLBs this is very fraught!) For simple embedded systems it is easier to write a scheduler that just calls each possible function in turn (or functions from some active list). Nothing can block - every function has to return back to the scheduler before anything else can happen. This can even alleviate the need for most interrupts, if they are not completely time critical there is no point, for example, moving a receive ethernet frame from the rx ring to a software linked list - the function that processes the frame can directly inspect the receive ring. In a real MP scheduler all the blocking functions will, in some way, be implemented with code that runs with spin lock held.