+ Reply to Thread
Results 1 to 8 of 8

Thread: Multitasking OS

  1. #1
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340

    Default Multitasking OS

    I am attempting to develop a multitasking operating system (RTOS) in PDS. Practically it will only be suitable for the 18Series devices but it is beginning to look promising. It will be a co-operative scheduler which means each task in your program will have to Yield back to the OS at regular times. In its minimum form it will require about 700 bytes of program memory expanding to about 1800 bytes it you use all the bells and whistles.

    In use it can be make writing multitasking systems very simple. Here is an example:

    Code:
    GoTo start
    Include "RTOS Main.bas"
    Include "RTOS Macros.Inc"
    
    Dim Ctr As Byte
    
    Symbol T_Count  = OSTCBP(1)
    Symbol T_LEDOut = OSTCBP(2)
    Symbol T_OSCOut = OSTCBP(4)
    Symbol T_Delayed = OSTCBP(5)
    
    CountTsk:
    While 1 = 1
        Inc Ctr
        OS_Yield
    Wend
    
    LEDOut:
    While 1 = 1
        PORTD = Ctr & $0F
        OS_Yield
    Wend
    
    DelayedTask:
    While 1 = 1
        Toggle PORTA.5
        OSStartTask T_OSCOut
        OS_Delay 2
        OSStopTask T_OSCOut
        Toggle PORTA.5
        OS_Delay 10
    Wend
    
    OSCOut:
    While 1 = 1 
        PORTC = Ctr & $0F
        OS_Yield
    Wend
    In the above I have written 4 very simple routines:
    "CountTsk" increments a counter whenever it gets the opportunity.
    "LEDOut" places the lower nibble of the counter onto Port C to which 4 leds are attached.
    "OSCOut" does the same as LEDOut but on a different port.
    "DelayedTask" Toggles a port bit, starts another routine (OSCOut) and waits for 2 ticks, when it runs again it stops the OSCOut and waits for 10 ticks.

    Back to the example

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




    Code:
    OSInit          ' Initialise RTOS
    OSCreateTask T_Count, CountTsk, 3
    OSCreateTask T_LEDOut, LEDOut, 3
    OSCreateTask T_OSCOut, OSCOut, 3
    OSCreateTask T_Delayed, DelayedTask, 2
    
    OSStartTask T_Count
    OSStartTask T_LEDOut
    OSStartTask T_Delayed  ' delayed will start and stop OSCOut
    
    While 1 = 1
        OSSched     ' run scheduler continuously
    Wend
    This is the main program - We call OSInit which sets prepares the OS
    We then register each routine as a task specifying the priority level each task should take
    We start 3 of the tasks and then run the scheduler continuously.

    That's it - You now have routines running at different rates controlling each other or themselves all controlled by a scheduler.

    Its early stages at present and if you have read down as far as here I guess you must be a little interested. I am inviting other members who see the potential of this to join me in completing this project. The basic scheduling is written the areas now to work on are events which encompass Semaphores, and Messages. There will then be a need for quite a bit of testing and hopefully trials in some real applications.

    If anyone is interested in contributing to this project please PM me and we can discuss how we might work together.
    Last edited by johngb; 16th July 2011 at 11:56.
    JohnB


  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Super Moderator joesaliba's Avatar
    Join Date
    Sep 2004
    Location
    Malta
    Posts
    1,543


    Default Re: Multitasking OS

    John,

    You have two similar threads in this area of the forum. Is that purposly done or a mistake? If so, can I delete the other thread so we keep the forum clean please?

    Regards

    Joseph

  4. #3
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    Default Re: Multitasking OS

    I edited the first and ended up with 2 - please delete the earlier one.
    JohnB

  5. #4
    Licensed User ohararp's Avatar
    Join Date
    May 2005
    Location
    Dayton, OH, USA
    Posts
    893


    Default Re: Multitasking OS

    John, I will definitely stay tuned to this. I am doing some simple temperature controller stuff where this could be very handy.
    Regards Ryan

    $25 SMT Kapton Stencils - http://www.ohararp.com/

  6. #5
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    Default Re: Multitasking OS

    OK - not much of a response so far - I have moved on a bit now and do really need some people who would be prepared to put some time into testing this.

    I have attached a draft User Manual which I hope might stimulate some interest and explain better I hope what its all about.

    What I need is for people to try using this on a small project or invent some test programs ideally which could be run in ISIS. I know the RTOS code is bound to have bugs so please if you are going to join me in this be prepared for some frustrations but I will be here to give support and bug fix as quickly as possible.

    Please PM me if you want to join in with this and give me your email address where I can send the code.
    JohnB

  7. #6
    Licensed User ohararp's Avatar
    Join Date
    May 2005
    Location
    Dayton, OH, USA
    Posts
    893


    Default Re: Multitasking OS

    JohnB, I do apologize. I ended up getting the temperature controller I was working with going using a simple state machine.
    Regards Ryan

    $25 SMT Kapton Stencils - http://www.ohararp.com/

  8. #7
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    3 members found this post helpful.

    Default Re: Multitasking OS

    Real Time OS update P-RTOS:

    I now am able to offer my P-RTOS to anyone who would like to try developing programs using its facilities.

    It should run on any 18F series PIC(r) with a code space of 64Kbytes or less. At present it doesn't support PICs which use extended address space. It is fully configurable, you switch on only the services you need. Unless you are doing something very simple you will need a real-time clock which you can configure to TMR0 or TMR1 or an external source.

    Your program has to be written as a number of Tasks and the operating system will then run those tasks at the appropriate time. For those familiar with writing programs in Visual Basic a task could be viewed as the code you write in response to an event in Windows.

    P-RTOS uses co-operative scheduling which means that each task must yield back to the OS for other tasks to run. All OS calls are implemented as through macros which provide a clean and consistent interface.

    The P-RTOS is provided as in 4 include files and a skeleton main program which you can use to build your own application.

    Currently the P-RTOS supports the following:

    Continuous Tasks - i.e. tasks which run continuously unless interrupted by a higher priority task
    Delayed Tasks - i.e. a Task which runs then waits before running again.
    Cyclic Timers - i.e. Routines which run automatically at a pre-determined rate.
    Buffered Serial input and serial output - i.e. using the hardware USART both Tx and Rx will be under interrupt contriol

    Tasks can communicate with each other using events. These can take the form of ...
    Semaphores - i.e. One task will wait on a Value signalled by another task or an event such as an interrupt.
    Binary Semaphores - i.e. a special case semaphore where the value has one of 2 states.
    Messages - i.e. One task waits on a Message sent by another task. This can be any variable supported by PDS.

    Once you have got your head around this approach to coding you will find you can produce quite complex programs very quickly and with minimal new code.

    Please contact me by PM if you are interested in trying this out.
    JohnB

  9. #8
    Licensed User Cruster's Avatar
    Join Date
    Nov 2003
    Location
    Gloucester
    Posts
    742


    Default Re: Multitasking OS

    Quote Originally Posted by johngb View Post
    ... please contact me by PM if you are interested in trying this out.
    Hi John,

    Tried unsuccesfully, but your mailbox appears to be full!

+ Reply to Thread

Similar Threads

  1. multitasking..
    By lockman_akim in forum Projects discussion
    Replies: 6
    Last Post: 8th February 2011, 11:40

Members who have read this thread since 2nd May 2012, 14:27 : 1

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts