When a task is scheduled with one of the real-time scheduling policies (that is, SCHED_RR or SCHED_FIFO), you may need to yield the task from the processor (yielding the task means to relinquish the CPU, making it available to other tasks). As we described in the Learning to set and get a scheduler policy recipe, when a task is scheduled with the SCHED_FIFO policy, it does not leave the processor until a certain event occurs; that is, there is no concept of a timeslice. This recipe will show you how to yield a process with the sched_yield() function.
Learning how to yield the processor
How to do it...
In this recipe, we'll develop a program that will yield the current process:
- On a shell, open a new source...