Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/17/04 17:58
Read: times


 
#76061 - RE: 8051 Context Switching
Responding to: ???'s previous message
Yes, and probably the OS should provide wrapper functions for all the SFRs, some memory allocation scheme etc. And either you include whole stack in the context or chop the memory into multiple tiny (easy to overflow) stacks.

Personally I'd see it like this:
You get a rather big chunk of XRAM (actual RAM or NVRAM).
Each time the system takes over, great most of scratchpad (exception: some SFRs for which wrapper functions exist, i.e. timers, serial, interrupts) are backed up in the XRAM, scratchpad for the next task is recovered from XRAM, its system IO requests are fulfilled and its work resumed (i.e. for a clocked period of time).
This way the task has all the general registers at its disposal and very few limitations - there are really few "forbidden operations". BUT at what cost? About 1000 cycles wasted for each task switch. Awful overhead. And some really awkward API to provide exclusive access to "restricted SFRs".

People think an OS for '51 is a bad idea because of the overhead it creates. And that's true, what good is an OS for, if it eats up great most of the CPU time leaving none for the applications?

If you REALLY REALLY want an OS, build a simple non-multitasking layer similar to DOS, where by means of a simple user interface you can pick application to launch, and when the application ends, the program falls back to the OS. This way user still will have games and notepad, they just won't be able to use them both AT ONCE! (who can type notes and play games -simultaneously- anyway?) You can even provide some neat OS-level services like display functions, RTC, keyboard driver and such, based on interrupts. But not multitasking. Multitasking is just too much for a '51.

List of 24 messages in thread
TopicAuthorDate
8051 Context Switching            01/01/70 00:00      
   Why??            01/01/70 00:00      
      RE: Why??            01/01/70 00:00      
         RE: On an 8051??            01/01/70 00:00      
            RE: On an 8051??            01/01/70 00:00      
   RE: 8051 Context Switching            01/01/70 00:00      
   RE: 8051 Context Switching            01/01/70 00:00      
      RE: 8051 Context Switching            01/01/70 00:00      
         RE: 8051 Context Switching            01/01/70 00:00      
            RE: 8051 Context Switching            01/01/70 00:00      
               RE: 8051 Context Switching            01/01/70 00:00      
                  RE: 8051 Context Switching            01/01/70 00:00      
                     RE: 8051 Context Switching            01/01/70 00:00      
                        RE: 8051 Context Switching            01/01/70 00:00      
                           RE: 8051 Context Switching            01/01/70 00:00      
                              RE: 8051 Context Switching            01/01/70 00:00      
                                 RE: 8051 Context Switching            01/01/70 00:00      
                                    RE: 8051 Context Switching            01/01/70 00:00      
                                       RE: 8051 Context Switching            01/01/70 00:00      
                                          RE: 8051 Context Switching            01/01/70 00:00      
                                             RE: 8051 Context Switching            01/01/70 00:00      
               RE: 8051 Context Switching            01/01/70 00:00      
   RE: 8051 Context Switching            01/01/70 00:00      
   RE: 8051 Context Switching            01/01/70 00:00      

Back to Subject List