This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Multiple thread support in eCos


Hi Andrew,

Thanks for your response. 
As far as the kerner configuration is concerned, I haven't changed anything in the original ecos.ecc file except some small changes for run time memory usage and things like that. Please find furthur clarifications on your queries:

1. Thanks for the clarification that ecos threads are not maintained in a tree like structure and will continue to work even after the main exits.

2. What I ment by threads running simultaneously is, atleast both the threads should continue to execute on a time sharing basis. But in my case both the threads get executed once and stop.

3. I was just trying to print from 1 to 10 in threads and there is no significance for that. 

4. You had mentioned in your response mail that there should not be context switch within the threads, but the way I am priting is to use the second serial port available on the board and sending the debug messages to the Hyper terminal application. This is a context switch, could this be causing any issues?

Your suggestions surely help me resolving the issues I am facing.

Please find the application source code also pasted below.

#include "DIAG_Debug.h"
#include "OS_Thread.h"
#include "OS_Timer.h"
#include "OS_Event.h"

uint32	ghConnectEvt[2];

#define INFINITE    0xffffffff	

static void thread_1(void *pvData)
{
    unsigned char i;
    while(1)
    {
	for(i=0; i<10; i++)
        {	
           MSG_DebugInfo_SYS(("i=%d", i));
        }
    }
}

static void thread_2(void *pvData)
{
    unsigned char j=10;
    while(1)
    {
	for(j=0; j<10; j++)
        {
            MSG_DebugInfo_SYS(("j=%d", j));
        }
    }
    
}

void timeoutFunc(void *pvData)
{
    static unsigned char iCount = 0;

    if(iCount == 0)
    {
	OS_SetEvent(ghConnectEvt[1]);
	iCount = 1;
    }
    else if(iCount == 1)
    {
	OS_SetEvent(ghConnectEvt[0]);
	iCount = 0;
    }
}


int main(void)
{
    int i = 0;
    CallbackFuncData *hTimer;

    MSG_DebugInfo_SYS(("OS Thread tester"));
    
    /* Create threads and then the start the timer */
    OS_CreateThread(thread_1, NULL);
    OS_CreateThread(thread_2, NULL);
    
    hTimer = OS_StartTimerInfinite(1000,      (TimerCallbackFunc)timeoutFunc, NULL);

    OS_WaitForEvent(ghConnectEvt[0], INFINITE);	
    return 0;         	
}

All timer and thread calls are through abstraction layer written for eCos.

Thanks & Regards,
-Ravi

-- 
____________________________________________
http://www.operamail.com
Get OperaMail Premium today - USD 29.99/year


Powered by Outblaze

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]