[ECOS] question about Synchronization Levels in eCOS? Thanks alot.
Tue May 6 13:26:00 GMT 2003
Suppose the following:
cyg_flag_wait( &flag );
// if cyg_flag_setbits(&flag) called here what problem would be?
// if cyg_flag_setbits(&flag) called here would this be OK?
Q1: But can I awaken a thread in DSR( ) by calling cyg_flag_setbits( ) ?
Q2: If I use the cyg_flag_setbits( ) in ISR( ) to awaken a thread what problem would happen? (affect the IRQ responsing time?)
Thanks a lot.
From: Gary D. Thomas [mailto:email@example.com]
Sent: 06 May 2003 14:13
Cc: eCos Discussion
Subject: Re: [ECOS] question about Synchronization Levels in eCOS?
On Tue, 2003-05-06 at 06:51, QiangHuang wrote:
> Hi all:
> I have some question about the Synchronization Levels in ecos. Can I set
> the flag bit or post semaphore in a ISR()? if not why? As mentioned in the
> ecos doc as:
> " Since it would be dangerous for an ISR or DSR to make a call that might
> reschedule the current thread (by trying to lock a mutex for example) all
> functions in this API have an associated synchronization level. "
> I can't completely understand why calling a function :
> yg_drv_cond_signal( ) in isr() or dsr() should be forbidden. Is this just
> to signal a condiction probably awaken a waiting thread. Then the awaken
> thread might be able to run after exiting isr( ) and dsr( ), if this is
> thread that the application want to run when such IRQ occured. so why ? how
> does this compare to "cyg_flag_setbits( )" and "cyg_semaphore_post( )"
This is illegal because ISR routines can be called at any point
that interrupts are enabled. This includes during what some
systems call "critical sections", e.g. places where the kernel
is manipulating it's own internal data structures etc.
We allow ISR routines to be called like this in order to keep
interrupt response time to a minimum. The ISR is then expected
to dispatch a DSR if more extensive (or dangerous) operations
are required. In this way, pure interrupt response time is
minimized and the kernel is kept fast and simple.
Gary D. Thomas <firstname.lastname@example.org>
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss
More information about the Ecos-discuss