From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 857 invoked by alias); 12 Apr 2011 21:33:25 -0000 Received: (qmail 844 invoked by uid 22791); 12 Apr 2011 21:33:24 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from hermes.mlbassoc.com (HELO mail.chez-thomas.org) (64.234.241.98) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Apr 2011 21:33:19 +0000 Received: by mail.chez-thomas.org (Postfix, from userid 999) id 285D516606AB; Tue, 12 Apr 2011 15:33:18 -0600 (MDT) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by mail.chez-thomas.org (Postfix) with ESMTP id 5D62116606A9; Tue, 12 Apr 2011 15:33:16 -0600 (MDT) Message-ID: <4DA4C51B.2070409@mlbassoc.com> Date: Tue, 12 Apr 2011 21:33:00 -0000 From: Gary Thomas User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc13 Thunderbird/3.1.7 MIME-Version: 1.0 To: moktar_bouain CC: ecos-devel@ecos.sourceware.org Subject: Re: I have a problem with the priority of ecos References: <31383032.post@talk.nabble.com> In-Reply-To: <31383032.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: 2011-04/txt/msg00001.txt.bz2 On 04/12/2011 03:25 PM, moktar_bouain wrote: > > Hello , > I have a problem with the priority of ecos. > I have the following configuration: > > #include > > #include > #include > #include > cyg_thread thread_s[2]; > char stack[2][4096]; > cyg_handle_t simple_threadA, simple_threadB; > cyg_mutex_t cliblock; > void taska(cyg_addrword_t data) > { > printf("TASKA \n"); > } > void taskb(cyg_addrword_t data) > { > printf("TASKB \n"); > > } > > void cyg_user_start(void) > { > printf("Entering twothreads' cyg_user_start() function\n"); > > cyg_mutex_init(&cliblock); > > cyg_thread_create(10, taska, (cyg_addrword_t) 0,"Thread A", (void *) > stack[0], 4096,&simple_threadA,&thread_s[0]); > cyg_thread_create(0, taskb, (cyg_addrword_t) 1,"Thread B", (void *) > stack[1], 4096,&simple_threadB,&thread_s[1]); > } > > void main (cyg_addrword_t data) > { > for(;;) > { > cyg_thread_resume(simple_threadA); > cyg_thread_resume(simple_threadB); > } > } > > when I execute this configuration: > TASKB > TASKB > TASKB > TASKB > TASKB > TASKB > TASKB > TASKB > TASKB > TASKB > TASKB > > but when I changed the priority: > > cyg_thread_create(1, taska, (cyg_addrword_t) 0,"Thread A", (void *) > stack[0], 4096,&simple_threadA,&thread_s[0]); > cyg_thread_create(0, taskb, (cyg_addrword_t) 1,"Thread B", (void *) > stack[1], 4096,&simple_threadB,&thread_s[1]); > I find this false result > TASKB > TASKA > TASKB > TASKA > TASKB > TASKA > TASKB > TASKA > TASKB > TASKA > TASKB > TASKA > TASKB > TASKA > TASKB > > Any help?? What scheduler are you using? (this controls how many priorities and what type of priority mechanism is available) Also, what makes you think that after a thread does a printf() call, it should yield the CPU to the other thread? There is no reason for it and in the simplest configuration printf() is just diag_printf() which is not interrupt driven and there would never be a reason for one thread to lose control of the CPU. -- ------------------------------------------------------------ Gary Thomas | Consulting for the MLB Associates | Embedded world ------------------------------------------------------------