This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: a confusion regarding role of schedlock
- From: NavEcos <ecos at navosha dot com>
- To: Brij Bihari Pandey <fuzzhead012 at yahoo dot com>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: 13 Sep 2002 00:57:17 -0700
- Subject: Re: [ECOS] a confusion regarding role of schedlock
- References: <20020913070128.14264.qmail@web21006.mail.yahoo.com>
I'm not positive but I think I have the explanation to the seemingly odd
code below. The call to Cyg_Scheduler::reschedule() unlocks the
scheduler:
FILE : kernel/current/include/sched.inl
inline void Cyg_Scheduler::reschedule()
{
// This function performs the equivalent of calling unlock() and
// lock() is succession. Unlike that pair, however, it does not
// leave a brief window between the calls when the lock is unclaimed
// by the current thread.
CYG_INSTRUMENT_SCHED(RESCHEDULE,get_sched_lock(),0);
unlock_inner( get_sched_lock() );
}
The last line unlocks the scheduler, no matter what the lock count is.
-Rich
On Fri, 2002-09-13 at 00:01, Brij Bihari Pandey wrote:
> hi list,
>
> Out of interest to know about an RTOS, I am browsing
> through the eCos source code (is there any other GPL
> RTOS available, source code of which i can download
> and browse??)
>
> Please don't mind if my doubts sound stupid.
>
> I came across this piece of code in cnt_sem.cxx, that
> confused me a bit.
>
> cyg_bool Cyg_Counting_Semaphore::wait()
> {
> -- ..... --
> // Prevent preemption
> Cyg_Scheduler::lock();
> -- ..... --
> // Allow other threads to run
> Cyg_Scheduler::reschedule();
> -- ..... --
> // Unlock the scheduler
> Cyg_Scheduler::unlock();
> -- ..... --
> }
>
> In the beginning we take schedlock to prevent
> preemption and then we ourselves allow other threads
> to run while schedlock is still non-zero?
>
> may be similar kind of situations are in more places?
>
> brij
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
>
> --
> Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
> and search the list archive: http://sources.redhat.com/ml/ecos-discuss
>
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss