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

Multi threading not working on RTX Kernel fro LPC1768

I am trying to configure RTX Kernel for LPC1768.
I use RTX help from "http://www.keil.com/support/man/docs/rlarm/rlarm_ar_create_newapp.htm"

In the help a file named RTX_Config.c is suggested (but it is not there at the suggested place) then I imported RTX_Conf_CM.c. Rest of the steps I have followed.

But still Only one execution thread is running.
here is structure of my code.

__task void CommandHandeler (void);
__task void init(void);
__task void MainThread(void);

__task void init(void)
{
        Print("Check 5.");
        os_tsk_create (MainThread, 2);
        Print("From thread 0");
        os_tsk_create (CommandHandeler, 1);

        while(1)
                os_dly_wait (5);
}

__task void MainThread(void)
{


        while(1)
        {
                delay(10000);
                Print("From thread 1.");
        }
}

__task void CommandHandeler(void)
{
        Action Act;
        while(1)
        {
                delay(20000);
                Print("From thread 2.");
        }

}

int main (void)
{
        SystemInit();
        SystemClockUpdate();
        UARTInit(0, 9600);      /* baud rate setting */
        os_sys_init(init);
}

This is the Output of that coded:
Check 5.
From thread 1.
From thread 1.
From thread 1.
: :

Rest of the print never comes.

Thanks in advance.

Parents Reply Children
  • __task void init(void)
    {
            Print("Check 5.");
            os_tsk_create (MainThread, 1);
            Print("From thread 0");
            os_tsk_create (CommandHandeler, 1);
    
            while(1)
                    os_dly_wait (5);
    }
    

    change the priority of MainThread to 1, as the above shows, then see what will happen.

  • But you ignored the issue I was talking about.

    How long is your delay? Is it a busy loop? Can't it be modified to sleep the thread?

    It doesn't matter what thread priorities you use or if you get your threading to work or not. Busy-loops should be avoided whenever possible in a multithreaded system, unless we are talking about an "idle" thread that only runs when there is nothing else to do.

    If you have one thread with higher priority, and you let it busy-loop, then you will starve all other threads. A high-prio thread will only give CPU to less prioritized threads if it is helpful and calls any function that puts the thread to sleep while waiting for something.