simulating a cooperative scheduler

I have developed a very simple cooperative scheduler for my embedded systems. Now I would like to test and to improve its performaces and features. How can I simulate a cooperative scheduler on a preemptive operating system such as linux or windows?

thanks

--
Mastupristi?

Posted from X-Privat Free NNTP server - www.x-privat.org
Reply to
Mastupristi
Loading thread data ...

Well, you can simulate it executing dummy tasks in a loop, or real tasks themselves, all in a single OS-level process.

How does the scheduler work? Your processes call a yield() primitive that saves context, runs the scheduler to choose the next task, then restores the context? If so, then write a loop like so:

int current_task; int tick = 0;

while(1) { current_task = scheduler (); printf ("%d: Running %d\n", tick, current_task); tick++; }

...and look at the logs to see if all tasks got run sufficiently. To make it more interesting, you can start altering whatever scheduling parameters you have for tasks - putting code in the loop to, at certain points in time according to a script, make tasks alter their priorities, block and unblock, etc.

Thus you can test the interesting algorithmic bits without needing to worry about porting the machine-dependent context save/restore code.

ABS

Reply to
Alaric B Snell

there exist some primitives that call the scheduler. One primitive is yield(). Yield calls scheduler that coose another task ready to be executed, ad switch the context. My tasks do not have priorities. The scheduler just apply roud robin philosophy to coose the next task.

I don't understand where you suggest to put this loop. In the scheduler?

thanks

--
Mastupristi?

Posted from X-Privat Free NNTP server - www.x-privat.org
Reply to
Mastupristi

Hi, If the scheduler is written in C, then you could verify functional behaviour by writing a normal Windows app (either in Borland C++ or Visual Studio or whatever) and then use the debugger. The app could consist of several test tasks and the main program would initialise & launch the scheduler. If you're really adventurous, you could devise a "Task" class where Task objects could be instantiated and automatically added to some scheduler task list. If the code isn't written in C, then the only way to test it is either to run it on a target system or on an appropriate simulator. For instance if the scheduler was written for the 8051, then you could use the SDCC compiler tools and any of the free simulators that are available. To gauge performance, some simulators provide the facility to count machine cycles. I can't remember the name of the 8051 simulator that I had used in the past, but I'm sure that a Google search would find some.

Ken.

+====================================+ I hate junk email. Please direct any genuine email to: kenlee at hotpop.com
Reply to
Ken Lee

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.