This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Scheduler Problem
- From: Iztok Zupet <iz at vsr dot si>
- To: "James Yates" <j dot yates at quartzuk dot com>,<ecos-discuss at sources dot redhat dot com>
- Date: Mon, 13 Oct 2003 13:26:14 +0200
- Subject: Re: [ECOS] Scheduler Problem
- Organization: VSR d.o.o.
- References: <CB39E7B8FC98924D85DFBED207E4CC98344208@ip02.quartzelec.adsl.gxn.net>
- Reply-to: iz at vsr dot si
On Monday 13 October 2003 13:20, James Yates wrote:
> I have just ported eCos to my own custom SH2 platform and I am now at the
> point of getting a simple app up and running. I have a bootloader running
> on my board which copies the executable from flash to RAM, sets the CPU VBR
> to the correct location and jumps to the address held in the first entry of
> the table. My app starts in cyg_user_start where I can print some
> diagnostic out of the serial port. I am infact using the example app code
> from the "Embedded Software Development with eCos" book. This creates 2
> threads, sets them to resume when the scheduler then exits cyq_user_start
> where as I understand it, the scheduler is then started. After a couple of
> seconds, a load of rubbish is printed out of the serial portand then
> nothing else. It would appear that the first thread is starting and
> something is going horribly wrong but I am not sure what.
>
> Has anyone had any similar problems in this area or can offer any
> suggestions?
>
> Example code below:
>
> void thread_a( cyg_addrword_t data )
> {
> // Store the data value passed in for this thread.
> int msg = (int)data;
>
> diag_printf("Thread A Start\n" );
>
> while( 1 )
> {
> // Increment the thread a count.
> thread_a_count++;
>
> // Send out a message to the diagnostic port.
> diag_printf( "Thread A, count: %d message: %d\n", thread_a_count, msg );
>
> // Delay for 1 second.
> cyg_thread_delay( 100 );
>
> // Signal thread B using the semaphore.
> cyg_semaphore_post( &sem_signal_thread );
> }
> }
>
> void thread_b( cyg_addrword_t data )
> {
> // Store the data value passed in for this thread.
> int msg = (int)data;
>
> diag_printf("Thread B Start\n" );
>
> while( 1 )
> {
> // Signal thread B using the semaphore.
> cyg_semaphore_wait( &sem_signal_thread );
>
> // Send out a message to the diagnostic port.
> diag_printf( "Thread B, message: %d\n", msg );
> }
> }
>
> void cyg_user_start( void )
> {
> // Initialize the count for thread a.
> thread_a_count = 0;
>
> // It wouldn't be much of a basic example if some
> // kind of hello message wasn't output.
> diag_printf( "Hello eCos World!!!\n" );
>
> // Initialize the semaphore with a count of zero,
> // prior to creating the threads.
> cyg_semaphore_init( &sem_signal_thread, 0 );
>
> diag_printf( "Point 2\n" );
>
> //
> // Create our two threads.
> //
> cyg_thread_create(
> THREAD_PRIORITY,
> thread_a,
> (cyg_addrword_t) 75,
> "Thread A",
> (void *)thread_a_stack,
> THREAD_STACK_SIZE,
> &thread_a_hdl,
> &thread_a_obj );
>
> cyg_thread_create(
> THREAD_PRIORITY,
> thread_b,
> (cyg_addrword_t) 68,
> "Thread B",
> (void *)thread_b_stack,
> THREAD_STACK_SIZE,
> &thread_b_hdl,
> &thread_b_obj );
>
> // Resume the threads so they start when the scheduler
> // begins.
> diag_printf( "Point 3\n" );
> cyg_thread_resume( thread_a_hdl );
> cyg_thread_resume( thread_b_hdl );
You should start the scheduler here, otherwise it's never started:
Cyg_Scheduler::scheduler.start(); // This function never returns
>
> diag_printf( "Point 4\n" );
>
> }
Regards
Iztok
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss