From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12113 invoked by alias); 23 Nov 2006 08:43:14 -0000 Received: (qmail 11951 invoked by uid 22791); 23 Nov 2006 08:43:12 -0000 X-Spam-Status: No, hits=2.7 required=5.0 tests=AWL,BAYES_50,DK_POLICY_SIGNSOME,DK_POLICY_TESTING,DK_SIGNED,DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS X-Spam-Check-By: sourceware.org Received: from web38704.mail.mud.yahoo.com (HELO web38704.mail.mud.yahoo.com) (209.191.125.80) by sourceware.org (qpsmtpd/0.31) with SMTP; Thu, 23 Nov 2006 08:43:04 +0000 Received: (qmail 89902 invoked by uid 60001); 23 Nov 2006 08:43:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=zDsR77ii0ywHMDbIYP4xLskOWTwpyv0T0asCL8jfKZtRwhiF+qDA2A2Vv0bz2dEN8czIE4SjBiGYjtmB4nUoXtA6H1Q6prQVdpWp1nj/HNOpCZng1flTgf2PV4jE8jurGhBq9ExaLDF1eB1MBVKAsBUNi4MwBQ51YLUwZr3RkCk= ; Message-ID: <20061123084302.89900.qmail@web38704.mail.mud.yahoo.com> Received: from [86.34.3.57] by web38704.mail.mud.yahoo.com via HTTP; Thu, 23 Nov 2006 00:43:02 PST Date: Thu, 23 Nov 2006 08:43:00 -0000 From: David Luca Subject: Unexpected exit from threads To: ecos-devel , ecos-discuss MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Mailing-List: contact ecos-devel-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-devel-owner@ecos.sourceware.org X-SW-Source: 2006-11/txt/msg00023.txt.bz2 Hello, I tried the example found in twothreads.c, but renamed the file to hello.cpp to compile it with g++. I commented the printf calls and replaced with lighting led functions. The code looks like: void Led(int led) { int j; for(j=0;j<100000;j++) GPIO_clr(led); for(j=0;j<100000;j++) GPIO_set(led); } /* now declare (and allocate space for) some kernel objects, like the two threads we will use */ cyg_thread thread_s[2]; /* space for two thread objects */ char stack[2][4096]; /* space for two 4K stacks */ /* now the handles for the threads */ cyg_handle_t simple_threadA, simple_threadB; /* and now variables for the procedure which is the thread */ cyg_thread_entry_t simple_program; /* and now a mutex to protect calls to the C library */ cyg_mutex_t cliblock; #ifdef __cplusplus extern "C"{ #endif void _impure_ptr()//required for C++ new operator { } /* we install our own startup routine which sets up threads */ void cyg_user_start(void) { // printf("Entering twothreads' cyg_user_start() function\n"); cyg_mutex_init(&cliblock); cyg_thread_create(4, simple_program, (cyg_addrword_t) USR_LED0, "Thread A", (void *) stack[0], 4096, &simple_threadA, &thread_s[0]); cyg_thread_create(4, simple_program, (cyg_addrword_t) USR_LED1, "Thread B", (void *) stack[1], 4096, &simple_threadB, &thread_s[1]); cyg_thread_resume(simple_threadA); cyg_thread_resume(simple_threadB); } #ifdef __cplusplus };//extern "C"{ #endif /* this is a simple program which runs in a thread */ void simple_program(cyg_addrword_t data) { int message = (int) data; int delay; // printf("Beginning execution; thread data is %d\n", message); // cyg_thread_delay(200); for (;;) { delay = 200 + (rand() % 50); /* note: printf() must be protected by a call to cyg_mutex_lock() */ cyg_mutex_lock(&cliblock); { Led(message); //light up/down led in 2 tasks // printf("Thread %d: and now a delay of %d clock ticks\n", // message, delay); } cyg_mutex_unlock(&cliblock); cyg_thread_delay(delay); } } When I run this example, I can see that each of the 2 leds are lit, then the threads exits without continuing. Is there something wrong with the scheduler? The platform used is based on Agilent AAED2000 (Arm920). If you have any ideas, please inform me. Thank you in advance, David Luca. ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com