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]

Re: cyg_scheduler_lock


Rafael Rodríguez Velilla wrote:
> 
>   I'm reading "eCos Reference Manual" and I see that
> cyg_scheduler_lock.
>    Locks the scheduler so that a context switch cannot occur. This can
> be used to protect data shared between a thread and a DSR, or between
> multiple threads, by surronding the critical region with
> cyg_scheduler_lock() and cyg_scheduler_unlock().
> 
> I don't understand that of protecting data between DSRs and threads?

It's only needed in threads, since DSRs may run asynchronously at any point
after an interrupt. The clock interrupt that can cause a reschedule is just
one such interrupt.
 
>   If I lock the scheduler during the thread then no DSR can occur, no
> other thread can gain the CPU.
>   Is it safe to use cyg_scheduler_lock or unlock inside a DSR?

Yes they are safe in a DSR as long as they are balanced (you only lock as
many as you unlock).

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine


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