This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why this progam in RTOS not running?

This is my source code, very simple.

#include <rtx51.h>
#include <stdio.h>
#include <math.h>
#include <REGX51.H>

void  task1 (void) _task_ 1 _priority_ 1
{
 P2_1 = 0;
 os_wait(K_TMO, 100, 0);
}


void  task2 (void) _task_ 2
{
 P2_1 = 1;
 os_wait(K_TMO, 100, 0);
}


void start (void) _task_ 0
{   os_set_slice(10000);
        os_create_task (1);
        os_create_task (2);
        os_delete_task (os_running_task_id ());
        P1=0;
}

void  main (void)
{  P2_3=0;
  os_start_system (0);

}

But when i use proteus to simulator this program, I see that : P2_3 is low, that ok. But P1 is always high. I think that the program doesn't run the funtion :void start (void) _task_ 0 . But I don't know why. Can you help me. Thank you very much.

Parents
  • Here is a quick modified code from the RTXTiny Example file.
    Bradford

    #include <rtx51tny.h>
    #include <reg51.h>
    
    sbit  Toggle = P2^1;
    
    /*****************************************************/
    /* Task 0 'job0': RTX-51 tiny starts execution with task 0             */
    /**************************************************/
    void start (void) _task_ 0
    {       os_create_task (1);
            os_create_task (2);
            os_delete_task (os_running_task_id ());
    }
    
    
    
    /****************************************************/
    /*   Task 1 'job1':  RTX-51 tiny starts this task with os_create_task (1)     */
    /***********************************************/
    
    void  task1 (void) _task_ 1
    {
     while(1){
     Toggle = 0;
     os_wait(K_TMO, 100, 0);
     }
    }
    
    
    /****************************************************/
    /*    Task 2 'job2':  RTX-51 tiny starts this task with os_create_task (2)    */
    /****************************************************/
    void  task2 (void) _task_ 2
    {
     while(1){
     Toggle = 1;
     os_wait(K_TMO, 100, 0);
     }
    }
    

Reply
  • Here is a quick modified code from the RTXTiny Example file.
    Bradford

    #include <rtx51tny.h>
    #include <reg51.h>
    
    sbit  Toggle = P2^1;
    
    /*****************************************************/
    /* Task 0 'job0': RTX-51 tiny starts execution with task 0             */
    /**************************************************/
    void start (void) _task_ 0
    {       os_create_task (1);
            os_create_task (2);
            os_delete_task (os_running_task_id ());
    }
    
    
    
    /****************************************************/
    /*   Task 1 'job1':  RTX-51 tiny starts this task with os_create_task (1)     */
    /***********************************************/
    
    void  task1 (void) _task_ 1
    {
     while(1){
     Toggle = 0;
     os_wait(K_TMO, 100, 0);
     }
    }
    
    
    /****************************************************/
    /*    Task 2 'job2':  RTX-51 tiny starts this task with os_create_task (2)    */
    /****************************************************/
    void  task2 (void) _task_ 2
    {
     while(1){
     Toggle = 1;
     os_wait(K_TMO, 100, 0);
     }
    }
    

Children
  • Thank you very much for your code. I compile it with RTX-51 Tiny. It run successfull. I see the change state on P2_1.

    Now I need to add the priority to the tasks. It means each task has different prioritys. And the program must use RTX-51 Full. From your code , I add the priority and compile with RTX-51 full. It's ok. But when I make simulation this program, I don't see any change state o P2_1. So I sets the same priority to task 1 and 2 . But that has no effect.

    This is the code:

    #include <rtx51tny.h>
    #include <reg51.h>
    
    sbit  Toggle = P2^1;
    
    /*****************************************************/
    /* Task 0 'job0': RTX-51 tiny starts execution with task 0             */
    /**************************************************/
    void start (void) _task_ 0
    {       os_create_task (1);
            os_create_task (2);
            os_delete_task (os_running_task_id ());
    }
    
    /****************************************************/
    /*   Task 1 'job1':  RTX-51 tiny starts this task with os_create_task (1)     */
    /***********************************************/
    
    void  task1 (void) _task_ 1 _priority_ 1
    {
     while(1){
     Toggle = 0;
     os_wait(K_TMO, 10, 0);
     }
    }
    
    /****************************************************/
    /*    Task 2 'job2':  RTX-51 tiny starts this task with os_create_task (2)    */
    /****************************************************/
    void  task2 (void) _task_ 2 _priority_ 1
    {
     while(1){
     Toggle = 1;
     os_wait(K_TMO, 10, 0);
     }
    }
    

    Could you give me advice?
    Thanks a lot!

  • Glad you have your first RTX Tiny running. I'm sorry but I do not have RTX Full on this computer so I do not have the documentation but have you added the correct header files for RTX Full? Have you selected the correct operating system under Targets -> Operating system? This will load the correct library files.
    That's about all I can remember of RTX Full without the documentation available to me at this time.
    Bradford