Is it possible to convert a cooperative OS to a preemptive OS? If so, what is the general procedure?
I'm working on a project with AllWinner Tina (F1C series), and I'd like to get an OS to run on it.
Since it is a relatively less popular chip from China, there's no FreeRTOS or other Western RTOS ports for it, and I'm not interested in porting everything from scratch.
There are three OSes that I can use right now, XBoot, RT-Thread and Linux.
Linux has the advantage of supporting all peripherals, but that's a feature that I don't need, besides I want as fast as possible boot time, so I'll just skip that part. Booting XBoot takes shorter than u-boot itself, rest alone Linux.
RT-Thread had a good port on this chip, but it was removed from official GIT and no future support will be given as RTT received funding from a VC, and part of the deal is RTT team must generate revenue, so their Tina port has been dumb down since then so they can sell proprietary products based on it.
Besides, I'm really not fond of scons. I prefer Makefile, and I hate Python. I'm a religiously firm C user for the past 15 years.
That leaves me with XBoot, an OS I had read inside out, and stripped it all the way down from 3.4MB to 230kB. I've got all drivers I needed to work, and I did quite some deep customization to it.
I'd be very prefer if I can modify XBoot from cooperative to preemptive, but I don't know how.
It has a scheduler already, and the libcpu part has context switching code already. I've also got the timer part done, so I can now generate ticks and call functions periodically. I think all I need is to call the scheduler periodically (which was called only upon yield(), as it was cooperative).
What do you think? If I add a tracer in scheduler structure to indicate the current task, and call yield() with that current task as its current task parameter, in a timer callback (and use some locking mechanism to make sure the timer doesn't switch a task during a task is yielding), should it work?