public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Multiple thread support in eCos
@ 2003-09-08 13:12 Ravi Joshi
  2003-09-08 13:46 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Ravi Joshi @ 2003-09-08 13:12 UTC (permalink / raw)
  To: ecos-discuss

Dear all,

I have a question about thread support in eCos. I have written a small program to test eCos threads. I am using Cirrus Logic EP7312 board for testing.

1. The program creates two threads thread_1 and thread_2 that continuously print integer values from 1 to 10 in while(1) so that the threads will not exit. The threads are being created in the main() function. 

2. But when the program runs on the board. The application stops after printing the integers 1 to 10 from both the threads and nothing seems to be happening after that. The main() function is waiting on an event that never gets set. This has been done to assure that the main should not exit since the threads are running continuously.

I am thinking of using the above approach in a Bluetooth protocol stack porting application in which 7 serial port servers will be waiting on 7 threads for the incoming connections. 

Here are my queries:
1. How do I know that multiple thread support has been enabled in the ecos kernel?

2. If not enabled, what are the steps to enable it?

3. Can multiple threads run simultaneously in eCos(scenario of multiple servers waiting for the incoming connections simultaneously)

4. Any clue why my appplication is not able to run multiple threads?

Any suggestions will be highly appreaciated.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Multiple thread support in eCos
  2003-09-08 13:12 [ECOS] Multiple thread support in eCos Ravi Joshi
@ 2003-09-08 13:46 ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2003-09-08 13:46 UTC (permalink / raw)
  To: Ravi Joshi; +Cc: ecos-discuss

On Mon, Sep 08, 2003 at 06:43:36PM +0530, Ravi Joshi wrote:

> 1. The program creates two threads thread_1 and thread_2 that
> continuously print integer values from 1 to 10 in while(1) so that
> the threads will not exit. The threads are being created in the
> main() function.

> 2. But when the program runs on the board. The application stops
> after printing the integers 1 to 10 from both the threads and nothing
> seems to be happening after that. The main() function is waiting on
> an event that never gets set. This has been done to assure that the
> main should not exit since the threads are running continuously.

The threads will continue to run after main has exited. eCos does not
put threads into a tree like unix processes. Threads are independent
of each other. Threads can terminate without affecting each other.

> Here are my queries:
> 1. How do I know that multiple thread support has been enabled in the ecos kernel?
> 
> 2. If not enabled, what are the steps to enable it?

It enabled by default, so unless you have some strange configuration,
it should be enabled.
 
> 3. Can multiple threads run simultaneously in eCos(scenario of
> multiple servers waiting for the incoming connections
> simultaneously)

Depends on how you define simultaneously. For true simultaneous
execution you need a SMP machine, which your hardware is not. For time
sharing simultaneous operation than eCos can do that.

> 4. Any clue why my appplication is not able to run multiple threads?

Lets see the source. You say they stop after printing 10? Why 10?
There should be no context switch if all you have is a plain while(1)
loop. 

     Andrew






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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Multiple thread support in eCos
  2003-09-08 14:04 Ravi Joshi
@ 2003-09-08 14:23 ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2003-09-08 14:23 UTC (permalink / raw)
  To: Ravi Joshi; +Cc: Andrew Lunn, ecos-discuss

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

And that is probably what is broken. Go back to plain eCos and write
your program again. It should work. Then add back your abstractions
one by one until you find which one is broken.

    Andrew

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] Multiple thread support in eCos
@ 2003-09-08 14:04 Ravi Joshi
  2003-09-08 14:23 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Ravi Joshi @ 2003-09-08 14:04 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: ecos-discuss

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-09-08 14:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-08 13:12 [ECOS] Multiple thread support in eCos Ravi Joshi
2003-09-08 13:46 ` Andrew Lunn
2003-09-08 14:04 Ravi Joshi
2003-09-08 14:23 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).