Hi
i want to learn rtos and i am not beginner at this . also i read the book . but that describe only CO-OPERATIVE SCHEDELULER . it is useful but for pre-emption ( like RTOS ) has no information .
I visit freertos.org and i read Fundermentals . but i need for more ! . it became more sophisticated even using rtos . there are many function . on the other ands creating and using task,tcb,semaphore ... are very difficult to see . can any one help me using rtos or give me detailed informaion on ... ?
There are no "the book" and no "the rtos".
If you need help using an RTOS, then you must specify exactly which RTOS you are having problems with. And books are best if written for this specific (RT)OS.
About semaphores etc. The concept is identical for all OS. The API and parameters may vary a bit, but a semaphore works conceptually the same in Windows as it does in any of the RTOS you may be able to find.
I wrote two small preemptive schedulers (for other chips, so that cannot possibly help you) and from my experience, the best you can do first is to understand fully how the context of your processor is maintained - and then: how is the system's stack organized? is it limited to a certain memory range? is there a separation between system stack and operator stack? you must have a good understanding of the building blocks of the chip. A good starting point is looking at some assembly - because you must use assembly to write a preemptive scheduler - namely at the entry and exit from interrupts. ask yourself: what is happening there, and why? note that an interrupt service routine that saves most/all of the registers, gets almost 50% of the job done. after saving the context (in your interrupt service routine - you probably want to use a hardware timer to invoke it), you need some logic to select the next task, and then to restore the select task's settings into the processor's registers. It really is not too hard, but you have to be careful: chips tend to differ in the details - a C167 saves the return address from an ISR in the system's stack which is restricted to a certain zone in RAM, while an ARM does not have such a restriction and saves the return address in R14 (LR). Am ARM also has different modes, and shadowed registers etc, which are absent from a C167. So start by fully understanding how that C51 works by reading C51 manuals. I am sure that you'd succeed. Then you'd have to start worrying about synchronization, timing etc. If you are interested, here is my C167 sample. I must say that there are a few annoying mistakes in it (semaphores that are not a 100% water tight, for example), but my current personal project for an ARM9 (not released yet - hopefully some) fixes them and is a much better, mature program (I hope): sourceforge.net/.../