From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29024 invoked by alias); 8 Jun 2006 18:06:26 -0000 Received: (qmail 29015 invoked by uid 22791); 8 Jun 2006 18:06:25 -0000 X-Spam-Check-By: sourceware.org Received: from sta-204-188-98-27.rockynet.com (HELO hermes.chez-thomas.org) (204.188.98.27) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 08 Jun 2006 18:06:22 +0000 Received: by hermes.chez-thomas.org (Postfix, from userid 999) id B5F0119501A4; Thu, 8 Jun 2006 12:05:06 -0600 (MDT) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by hermes.chez-thomas.org (Postfix) with ESMTP id 65EB719500BC; Thu, 8 Jun 2006 12:05:01 -0600 (MDT) From: Gary Thomas To: Monica Dsz Cc: ecos discuss In-Reply-To: <000501c68b1a$68b523b0$ea14a8c0@taurus> References: <000501c68b1a$68b523b0$ea14a8c0@taurus> Content-Type: text/plain Date: Thu, 08 Jun 2006 18:06:00 -0000 Message-Id: <1149789900.15359.183.camel@hermes> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 (2.6.1-1.fc5.2) Content-Transfer-Encoding: 7bit Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] why is it wrong to call cyg_semaphore_post() in ISR??? X-SW-Source: 2006-06/txt/msg00090.txt.bz2 On Thu, 2006-06-08 at 18:41 +0200, Monica Dsz wrote: > Hallo all, > > I am new to eCos(and also to embedded). The eCos documentation says that ISR > should not involve any kernel calls.But I want to know why > cyg_semaphore_post() is not allowed in ISR(Interrupt service routine). It > doesnt block. and i tried to use it though documentation says we shouldnt. > It worked for me with the following code. > > cyg_uint32 timer_isr(cyg_vector_t vector,cyg_addrword_t data) > { > led_toggle(); //Toggle the LED > > isr_counter++; //32 bit ISR counter > > cyg_interrupt_acknowledge( vector ); //acknowledge the Interrupt to the > processor > > cyg_semaphore_post( &intr_occured ); //give the semaphore,so that task > waiting for it wakes up > > return( CYG_ISR_HANDLED ); // Inform the kernel that ISR is > handled > } > > I wonder why in eCos,a semaphore cannot be posted in ISR. In VxWorks we can > give a semaphore in ISR. Can anybody give me a pointer to documentation or > an explanation for this. ISR functions can be called at any time, so it's possible that you could be executing code within the scheduler or even semaphore handling when the ISR runs. In this case, the various state [variables] in the system may not be in a consistent state and allowing the ISR to change them would be catastrophic. It's a trade off - do you prevent interrupts (hence ISR routines) from running during all data critical sections or do you simply not allow those [ISR] functions to execute code that might perturb critical data? eCos chooses the latter method which allows for lower interrupt latency by putting off things until the DSR can be safely run. -- ------------------------------------------------------------ Gary Thomas | Consulting for the MLB Associates | Embedded world ------------------------------------------------------------ -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss