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: Fw: infinite loop in cyg_thread_create() function


>>>>> "Vijay" == Vijay Padiyar <vijaypadiyar@hotmail.com> writes:

    Vijay> We are still facing the problem with thread creation that
    Vijay> we faced earlier. We are calling cyg_thread_create() from
    Vijay> inside a method inside a class:

    Vijay> It's as follows:

    <snip>

    Vijay>     cyg_thread_create(priority, (cyg_thread_entry_t
    Vijay> *)&contextStart,(cyg_addrword_t)this, tasknm, NULL, stackSize, &handle1,
    Vijay>                                                 &handle);

    <snip>

    Vijay> 'run()' is a method inside class 'Context'. Earlier we were
    Vijay> defining a stack as 'static char stack[STACKSIZE]' just
    Vijay> above the cyg_thread_create() call and passing '&stack[0]'
    Vijay> as the argument. That was causing problems.

    Vijay> But I read that passing 'NULL' will cause the
    Vijay> cyg_thread_create() function to automatically allocate
    Vijay> stack area on its own. But even with NULL, it doesn't seem
    Vijay> to be working. It gets stuck in the same infinite loop in
    Vijay> Cyg_thread::add_to_list() in thread.cxx, i.e. prev = NULL.

    Vijay> How do we overcome this problem?

You did not read that in the official documentation, see
http://ecos.sourceware.org/docs-latest/ref/kernel-thread-create.html
It is the application's responsibility to provide space for the thread
stack, not the kernel's, because that way the kernel does not depend
on dynamic memory allocation.

That page in the documentation has an example which shows how to use
cyg_thread_create() properly. 

Bart

-- 
Bart Veer                       eCos Configuration Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts

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


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