??? 09/12/07 04:28 Modified: 09/12/07 05:01 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#144418 - It is the architecture Responding to: ???'s previous message |
Craig said:
It's not the 8051 architecture that dictates whether or not multitasking is reasonable, it's potentially the speed and/or the amount of memory available. Well, sort of. Although a fast 8051 with lots of memory can certainly be made to support multitasking, whatever success that comes about will be in spite of the architecture and not because of it. Here's why: In most architectures, the stack pointer can be applied to a large address space. That means that some memory can be set aside for each task's stack, and that switching from one stack to another is as simple and quick as swapping a few registers and changing the stack pointer. In the 8051, however, the stack pointer only applies to the 128 or 256 bytes of internal data memory, and that's a problem. It means that a multitasking system must do one of two things:
Now having said all that, I don't believe that you should reflexively dismiss the idea of multitasking on an 8051 in every situation. If you've got good reasons to use the 8051, and a real need for a multitasker, then multitasking is quite workable using the second technique mentioned above, especially on a fast derivative. Some good news: There are some files here that show one way to do it. There is code for a simple, cooperative (i.e., not preemptive) multitasker and a small demo program that uses it. Some bad news: While this code is pretty well commented, it's unsupported and there is no collateral documentation, so you will have to dig some in order to understand how it works. Also, it is both compiler- and platform-dependent, so the chances that you will be able to compile it and run it without modification are probably near zero. -- Russ |