From: Adam Dunkels (adam_at_sics.se)
Date: 2002-12-29 17:05:26
Hi! On Thu, 2002-12-26 at 20:16, Ullrich von Bassewitz wrote: > On Thu, Dec 26, 2002 at 04:43:41PM +0100, TXG/MNX wrote: > > Would it be possible to write and OS like Lunix or some other OS like > > that completely in CC65? > > > > This would make coding for different platforms like c64, atari, apple II > > and other 6502 systems more interested. > > Using C instead of assembly is always a tradeoff: It will add some overhead to > your programs, but at the same time, development is a lot faster. Because an > operating system, especially one that does multitasking, is already at the > limits of the machine, chances are high that the additional overhead will make > it too large/slow. A second reason was already given by MagerValp: It is not > possible to write interrupt code or task switching code in C (this is true for > any C compiler - all operating systems I know have at least a small percentage > of assembler functions). I'd like to point out that it actually is possible to write a multitasker in pure C, but it requires some support from the underlying system. The GNU portable threads does this by using setjmp/longjmp together with a special trick using sigaction to set up extra stacks for the threads. See the following links: http://www.gnu.org/software/pth/ http://www.engelschall.com/pw/usenix/2000/pmt-html/ Futhermore, it might be worthwhile to step away from the unix-style preemptive multitasking idea, and consider some of the other ways to achieve multitasking. Non-preemptive multitasking has many advantages, in particular for smallish systems such as the 6502. It has a lower context switching overhead and the programs does not have to worry about preemption and does therefore not have to be reentrant. Event based multitasking, where a "task" is defined as a C function that only runs for a short while, and the scheduler just has to call the correct C function at the right time, is an alternative that has a very low overhead. The drawback with this scheme is that certain kinds of applications (usually those that do long-running computations) are hard to implement this way. Such applications are quite likely to be uncommon on the 6502. though :-) > C support for an operating system would be useful in the higher layers of the > OS, or in the application layer. The nice thing about C is that it saves a lot > of development time, so you can do more in the same time. Even if you rewrite > parts of it in assembler later, there may still be time savings, because the > assembly code is just a conversion of the working C code, and all algorithms > are already tested. I couldn't agree more with the above! :-) Cheers, /adam -- Adam Dunkels <adam_at_sics.se> http://www.sics.se/~adam/ ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-12-29 17:06:18 CET