public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Re:  Is main() a normal thread ?
@ 2003-09-29 10:58 Savin Zlobec
  2003-09-29 12:58 ` Claudio Leonel
  0 siblings, 1 reply; 7+ messages in thread
From: Savin Zlobec @ 2003-09-29 10:58 UTC (permalink / raw)
  To: cls, ecos-discuss

Claudio Leonel wrote:

> Hi all,
>
>I thought main() was a normal thread but if I ran the
>following application step by step in gdb there is no
>return from the function cyg_thread_delay(). Apparently
>it hangs in the call to cyg_thread_delay().
>

Check the CYGSEM_LIBC_STARTUP_MAIN_THREAD option -
it controls how main() is invoked (from an eCos thread or not).

savin


-- 
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] 7+ messages in thread

* Re: [ECOS] Re:  Is main() a normal thread ?
  2003-09-29 10:58 [ECOS] Re: Is main() a normal thread ? Savin Zlobec
@ 2003-09-29 12:58 ` Claudio Leonel
  2003-09-30  8:32   ` Savin Zlobec
  0 siblings, 1 reply; 7+ messages in thread
From: Claudio Leonel @ 2003-09-29 12:58 UTC (permalink / raw)
  To: Savin Zlobec; +Cc: ecos-discuss

Hi,

Savin Zlobec wrote:
> Claudio Leonel wrote:
> 
>> Hi all,
>>
>> I thought main() was a normal thread but if I ran the
>> following application step by step in gdb there is no
>> return from the function cyg_thread_delay(). Apparently
>> it hangs in the call to cyg_thread_delay().
>>
> 
> Check the CYGSEM_LIBC_STARTUP_MAIN_THREAD option -
> it controls how main() is invoked (from an eCos thread or not).

It is enabled: main() will be invoked as an eCos thread
with 8192 bytes of stack and priority 10.
If I interrupt the application in gdb and execute 'info threads'
main() appears in the thread list.

The most strange thing is that, I if precede 'cyg_thread_delay(100)'
with a diag_printf("..."), cyg_thread_delay() works and returns
after 100 ticks:

---------------------------------------------------------------
int main(void) {
   while (1) {
      diag_printf("...\n");    // Works if I insert this line !
      cyg_thread_delay(100);
   }	
}
---------------------------------------------------------------


Regards,
Claudio L. Salvadori



-- 
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] 7+ messages in thread

* Re: [ECOS] Re:  Is main() a normal thread ?
  2003-09-29 12:58 ` Claudio Leonel
@ 2003-09-30  8:32   ` Savin Zlobec
  2003-09-30 12:03     ` Claudio Leonel
  0 siblings, 1 reply; 7+ messages in thread
From: Savin Zlobec @ 2003-09-30  8:32 UTC (permalink / raw)
  To: Claudio Leonel; +Cc: ecos-discuss

Claudio Leonel wrote:

> Hi,
>
> Savin Zlobec wrote:
>
>> Claudio Leonel wrote:
>>
>>> Hi all,
>>>
>>> I thought main() was a normal thread but if I ran the
>>> following application step by step in gdb there is no
>>> return from the function cyg_thread_delay(). Apparently
>>> it hangs in the call to cyg_thread_delay().
>>>
>>
>> Check the CYGSEM_LIBC_STARTUP_MAIN_THREAD option -
>> it controls how main() is invoked (from an eCos thread or not).
>
>
> It is enabled: main() will be invoked as an eCos thread
> with 8192 bytes of stack and priority 10.
> If I interrupt the application in gdb and execute 'info threads'
> main() appears in the thread list.
>
> The most strange thing is that, I if precede 'cyg_thread_delay(100)'
> with a diag_printf("..."), cyg_thread_delay() works and returns
> after 100 ticks:
>
> ---------------------------------------------------------------
> int main(void) {
>   while (1) {
>      diag_printf("...\n");    // Works if I insert this line !
>      cyg_thread_delay(100);
>   }   
> }
> ---------------------------------------------------------------

Most strange. Maybe you should give more info about your configuration,
platform, eCos version and tools. Is the above all of your program or 
are you
doing something else before main (in cyg_user_start) ?

savin 




-- 
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] 7+ messages in thread

* Re: [ECOS] Re:  Is main() a normal thread ?
  2003-09-30  8:32   ` Savin Zlobec
@ 2003-09-30 12:03     ` Claudio Leonel
  2003-09-30 13:36       ` Savin Zlobec
  0 siblings, 1 reply; 7+ messages in thread
From: Claudio Leonel @ 2003-09-30 12:03 UTC (permalink / raw)
  To: Savin Zlobec; +Cc: ecos-discuss

> Claudio Leonel wrote:
> 
>> Hi,
>>
>> Savin Zlobec wrote:
>>
>>> Claudio Leonel wrote:
>>>
>>>> Hi all,
>>>>
>>>> I thought main() was a normal thread but if I ran the
>>>> following application step by step in gdb there is no
>>>> return from the function cyg_thread_delay(). Apparently
>>>> it hangs in the call to cyg_thread_delay().
>>>>
>>>
>>> Check the CYGSEM_LIBC_STARTUP_MAIN_THREAD option -
>>> it controls how main() is invoked (from an eCos thread or not).
>>
>>
>>
>> It is enabled: main() will be invoked as an eCos thread
>> with 8192 bytes of stack and priority 10.
>> If I interrupt the application in gdb and execute 'info threads'
>> main() appears in the thread list.
>>
>> The most strange thing is that, I if precede 'cyg_thread_delay(100)'
>> with a diag_printf("..."), cyg_thread_delay() works and returns
>> after 100 ticks:
>>
>> ---------------------------------------------------------------
>> int main(void) {
>>   while (1) {
>>      diag_printf("...\n");    // Works if I insert this line !
>>      cyg_thread_delay(100);
>>   }   }
>> ---------------------------------------------------------------
> 
> 
> Most strange. Maybe you should give more info about your configuration,
> platform, eCos version and tools. Is the above all of your program or 
> are you
> doing something else before main (in cyg_user_start) ?

It is all my program !
My configuration is:
- arm-elf tools from the eCos 2.0 package (gcc 3.2.1)
- eCos configuration 2.0
- eCos from cvs
- AT91EB55 evaluation board from Atmel with redboot in Flash with
   AT91M55800A CPU (ARM7TDMI).
- Development host: Linux 2.4.20

Now I am not using main() anymore and using cyg_user_start() instead
and continuing the project, but is not confortable to know that
something is wrong and can manifest itself in other ways.

Regards,
Claudio L. Salvadori





-- 
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] 7+ messages in thread

* Re: [ECOS] Re:  Is main() a normal thread ?
  2003-09-30 12:03     ` Claudio Leonel
@ 2003-09-30 13:36       ` Savin Zlobec
  2003-09-30 15:21         ` [ECOS] (Is main() a normal thread ?) problem was my fault Claudio Leonel
  0 siblings, 1 reply; 7+ messages in thread
From: Savin Zlobec @ 2003-09-30 13:36 UTC (permalink / raw)
  To: Claudio Leonel; +Cc: ecos-discuss

Claudio Leonel wrote:

>> Claudio Leonel wrote:
>>
>>> Hi,
>>>
>>> Savin Zlobec wrote:
>>>
>>>> Claudio Leonel wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I thought main() was a normal thread but if I ran the
>>>>> following application step by step in gdb there is no
>>>>> return from the function cyg_thread_delay(). Apparently
>>>>> it hangs in the call to cyg_thread_delay().
>>>>>
>>>>
>>>> Check the CYGSEM_LIBC_STARTUP_MAIN_THREAD option -
>>>> it controls how main() is invoked (from an eCos thread or not).
>>>
>>>
>>>
>>>
>>> It is enabled: main() will be invoked as an eCos thread
>>> with 8192 bytes of stack and priority 10.
>>> If I interrupt the application in gdb and execute 'info threads'
>>> main() appears in the thread list.
>>>
>>> The most strange thing is that, I if precede 'cyg_thread_delay(100)'
>>> with a diag_printf("..."), cyg_thread_delay() works and returns
>>> after 100 ticks:
>>>
>>> ---------------------------------------------------------------
>>> int main(void) {
>>>   while (1) {
>>>      diag_printf("...\n");    // Works if I insert this line !
>>>      cyg_thread_delay(100);
>>>   }   }
>>> ---------------------------------------------------------------
>>
>>
>>
>> Most strange. Maybe you should give more info about your configuration,
>> platform, eCos version and tools. Is the above all of your program or 
>> are you
>> doing something else before main (in cyg_user_start) ?
>
>
> It is all my program !
> My configuration is:
> - arm-elf tools from the eCos 2.0 package (gcc 3.2.1)
> - eCos configuration 2.0
> - eCos from cvs
> - AT91EB55 evaluation board from Atmel with redboot in Flash with
>   AT91M55800A CPU (ARM7TDMI).
> - Development host: Linux 2.4.20
>
> Now I am not using main() anymore and using cyg_user_start() instead
> and continuing the project, but is not confortable to know that
> something is wrong and can manifest itself in other ways. 

I agree, this should probably be investigated.
Did you try enabling asserts or/and doing something else before thread 
delay (diag_printf does a lot of things)?
Maybe you should try building ecos from another setup/template.

savin



-- 
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] 7+ messages in thread

* [ECOS] (Is main() a normal thread ?) problem was my fault...
  2003-09-30 13:36       ` Savin Zlobec
@ 2003-09-30 15:21         ` Claudio Leonel
  0 siblings, 0 replies; 7+ messages in thread
From: Claudio Leonel @ 2003-09-30 15:21 UTC (permalink / raw)
  To: Savin Zlobec; +Cc: ecos-discuss

Hi,

I found the problem why the following program
does not work as intended:
------------------------------------------------
int main(void) {
    while (1) {
       cyg_thread_delay(100);
    }
}
------------------------------------------------

It will work if the header file <cyg/kernel/kapi.h>
is included.

The reason is that the parameter of cyg_thread_delay()
is a 64 bit variable. Without the header file, the compiler
will pass a 32 bit variable and the most significant word
is undefined, and could be a huge value,
so cyg_thread_delay() will delay for much more than 100 ticks...

The problem had nothing to do with main(). In my other
test program which used cyg_user_start() and another
thread, the header file was included, so the problem
didn't occur...

The moral of the story for me is:
   Allways include the header files !!!


Regards,
Claudio L. Salvadori


-- 
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] 7+ messages in thread

* RE: [ECOS] (Is main() a normal thread ?) problem was my fault...
@ 2003-09-30 15:25 Doyle, Patrick
  0 siblings, 0 replies; 7+ messages in thread
From: Doyle, Patrick @ 2003-09-30 15:25 UTC (permalink / raw)
  To: 'Claudio Leonel', Savin Zlobec; +Cc: ecos-discuss

The other moral is: compile with -Wall, so that GCC whines about missing
function prototype.

The alternate moral is: if you were compiling with -Wall, and GCC didn't
whine, then please let us know, because that is a bug.

--wpd


> -----Original Message-----
> From: Claudio Leonel [mailto:cls@elaxys.com.br] 
> Sent: Tuesday, September 30, 2003 8:21 AM
> To: Savin Zlobec
> Cc: ecos-discuss@sources.redhat.com
> Subject: [ECOS] (Is main() a normal thread ?) problem was my fault...
> 
> 
> Hi,
> 
> I found the problem why the following program
> does not work as intended:
> ------------------------------------------------
> int main(void) {
>     while (1) {
>        cyg_thread_delay(100);
>     }
> }
> ------------------------------------------------
> 
> It will work if the header file <cyg/kernel/kapi.h>
> is included.
> 
> The reason is that the parameter of cyg_thread_delay()
> is a 64 bit variable. Without the header file, the compiler
> will pass a 32 bit variable and the most significant word
> is undefined, and could be a huge value,
> so cyg_thread_delay() will delay for much more than 100 ticks...
> 
> The problem had nothing to do with main(). In my other
> test program which used cyg_user_start() and another
> thread, the header file was included, so the problem
> didn't occur...
> 
> The moral of the story for me is:
>    Allways include the header files !!!
> 
> 
> Regards,
> Claudio L. Salvadori
> 
> 
> -- 
> Before posting, please read the FAQ: 
> http://sources.redhat.com/fom/ecos
> and search the list 
> archive: http://sources.redhat.com/ml/ecos-discuss
> 

-- 
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] 7+ messages in thread

end of thread, other threads:[~2003-09-30 15:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-29 10:58 [ECOS] Re: Is main() a normal thread ? Savin Zlobec
2003-09-29 12:58 ` Claudio Leonel
2003-09-30  8:32   ` Savin Zlobec
2003-09-30 12:03     ` Claudio Leonel
2003-09-30 13:36       ` Savin Zlobec
2003-09-30 15:21         ` [ECOS] (Is main() a normal thread ?) problem was my fault Claudio Leonel
2003-09-30 15:25 Doyle, Patrick

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).