You might want to take a look at a couple of projects that have come before. But first, you probably want to abandon all hope of re-using source code directly; whatever you are doing, it'll take refactoring to work on your target platform. ;-)
Have a look at the LNG (LUnix Next Generation) project, which includes preemptive multitasking (on the C64):
http://lng.sourceforge.net
Some Apple Contiki notes:
http://a2central.com/?p=1427