I am doing a round robin simulation on my dual core PC running Windows 10.
So I am using the windows port.
I am trying to create a task1, then in task1, I create a short task task2 with same priority, then I call taskyield() to give up the processor.
based on my understanding of the sheduling behaviour, task2 should always run after I call taskyield(), when task2 is completed, task1 will be schedule, if it is in a single processor environment.
However, what I experience is that sometimes task2 will be scheduled after taskyield() is called in task1, sometimes task1 will be running again after taskyield() is called.
May I check with you if the simulation version will utilized the dual processors when schedule the tasks with same priority?
I would prsume that the Windows simulator will run single (Windows) threaded (and thus single core) as that is the mode that most looks like the processors it runs on natively. What can happen if you have Preemption enable is that if the (simulated) timer tic occurs just after the call to taskyield(), then the taskyield call would switch to task2, and the time tick then switchs control back to task1.
Thank you Richard, but I think what you are refering to is the TIME_SLICING option, right?
When I disable TIME_SLICING option, when task1 call taskyield(), it will always come back to schedule task1 again.