This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about scheduler & sleep


Bart,

Thanks for the thoughtful answer! From your reply, I think I
can infer something else which I've been curious about...
namely, what is the difference between cyg_scheduler_lock()
and disabling interrupts.

It sounds like cyg_scheduler_lock() allows ISRs to run, but
DSRs will not get scheduled. Is that right?

Thanks!
/Jim

Bart Veer <bartv@ecoscentric.com> wrote:
>This will not work because the counter returned by cyg_current_time()
>is updated by a DSR associated with the clock interrupt. DSRs will
>only run when the scheduler is unlocked, thus ensuring that kernel
>calls from a DSR only happen when the system data structures are
>consistent. If you use lower-level functionality such as
>HAL_CLOCK_READ() you may be able to get it working.
>
>Instead I would suggest using thread priorities:
>
>    cyg_thread_set_priority(0)
>    start = cyg_current_time()
>    while ((start + 128) > cyg_current_time())
>        ;
>    cyg_thread_set_priority(old_pri)
>
>This will work as long as there are no other threads running at the
>highest priority - you may need to reorganize some thread priorities
>to ensure this. Also there could be problems with mutexes: switching
>thread priorities while owning a mutex is a bad idea; with the
>priority inheritance/ceiling code also manipulating thread priorities,
>things can get confused.
>
>A big advantage of this approach is that it allows for more selective
>blocking of threads, rather than pausing the entire processor for 128
>ticks. All you need to do is pick a slightly lower priority. Higher
>priority threads can still run during the 128 ticks, servicing I/O or
>whatever. Lower priority threads are blocked.
>
>Bart
>
>-- 
>Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
>and search the list archive: http://sources.redhat.com/ml/ecos-discuss
>


__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]