This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Scheduler Lock
- From: Jay Foster <jay at systech dot com>
- To: ecos-discuss <ecos-discuss at ecos dot sourceware dot org>
- Date: Mon, 25 Jan 2010 13:37:49 -0800
- Subject: [ECOS] Scheduler Lock
I am trying to understand the finer details of the scheduler lock. My
concern is with calling cyg_mutex_lock() from thread context, but with
the scheduler locked.
At first, I thought that this could be bad because it might cause a
deadlock if the mutex was already owned by another thread. The second
thread (with the scheduler locked) calling cyg_mutex_lock() would block,
but because the scheduler is locked, no other threads or DSRs could run.
Examining the code doesn't seem to support this. It looks like the
scheduler lock is on a per-thread basis. This seems potentially bad
since locking the scheduler does not guarantee that no other thread or
DSR will be prevented from running.
I wrote a test application that does:
creates and initializes a mutex.
locks the mutex.
creates a second thread.
sleeps
The second thread does:
locks the scheduler
waits for the mutex.
Everything works as expected. Other threads DO continue to get
scheduled and run and DSRs also run. It's like the scheduler lock in
the second thread did nothing. Is this because the second thread that
locked the scheduler called a kernel function (cyg_mutex_lock) that
causes the thread to block and to run the scheduler?
Just looking for some confirmation/clarification.
Jay
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss