Re: cyg_io_read blocking
Gary Thomas <gary <at> mlbassoc.com>
2005-04-08 12:44:00 GMT
On Fri, 2005-04-08 at 13:33 +0100, Bart Veer wrote:
> >>>>> "Raghu" == Raghu <raghu_dk <at> yahoo.com> writes:
>
> Raghu> Sample code of "cyg_io_read", "cyg_io_write" that blocks
> Raghu> when a thread is spawned, but if called from a functions
> Raghu> dosent.
>
> Raghu> void cyg_user_start( void )
> Raghu> {
> Raghu> cyg_thread_create( 4, serial_thread_handler, ...
> Raghu> );
> Raghu> cyg_thread_resume( handle );
> Raghu> }
>
> Raghu> void serial_thread_handler( cyg_addrword_t data )
> Raghu> {
> Raghu> cyg_io_lookup( &hdl );
> Raghu> for( ; ; ){
> Raghu> cyg_io_read( hdl, &ch, &len );
> Raghu> cyg_io_write( hdl, &ch, &len );
> Raghu> }
> Raghu> }
>
> Raghu> But if "serial_thread_handler" is directly called from
> Raghu> "cyg_user_start" as a function call, there is no
> Raghu> issues.
>
> cyg_user_start() is run during system startup, before the scheduler is
> started or interrupts are enabled. There is no way for the system to
> block at this time. Blocking involves transferring control to another
(Continue reading)