forked from len0rd/rockbox
Make mutexes a tiny bit leaner. There is no need for a separate locked semaphore since having an owning thread also indicates that it is locked. Rename member 'count' to 'recursion' since it counts reentry, not locks. Change presents no compatibility issues for plugins or codecs because the structure size goes down.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28901 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1d460b603f
commit
f387cdef21
3 changed files with 25 additions and 20 deletions
|
|
@ -142,17 +142,19 @@ struct event_queue
|
|||
struct mutex
|
||||
{
|
||||
struct thread_entry *queue; /* waiter list */
|
||||
int count; /* lock owner recursion count */
|
||||
int recursion; /* lock owner recursion count */
|
||||
#ifdef HAVE_PRIORITY_SCHEDULING
|
||||
struct blocker blocker; /* priority inheritance info
|
||||
for waiters */
|
||||
bool no_preempt; /* don't allow higher-priority thread
|
||||
to be scheduled even if woken */
|
||||
#else
|
||||
struct thread_entry *thread;
|
||||
struct thread_entry *thread; /* Indicates owner thread - an owner
|
||||
implies a locked state - same goes
|
||||
for priority scheduling
|
||||
(in blocker struct for that) */
|
||||
#endif
|
||||
IF_COP( struct corelock cl; ) /* multiprocessor sync */
|
||||
bool locked; /* locked semaphore */
|
||||
};
|
||||
|
||||
#ifdef HAVE_SEMAPHORE_OBJECTS
|
||||
|
|
@ -265,10 +267,17 @@ extern void mutex_init(struct mutex *m);
|
|||
extern void mutex_lock(struct mutex *m);
|
||||
extern void mutex_unlock(struct mutex *m);
|
||||
#ifdef HAVE_PRIORITY_SCHEDULING
|
||||
/* Temporary function to disable mutex preempting a thread on unlock */
|
||||
/* Deprecated temporary function to disable mutex preempting a thread on
|
||||
* unlock - firmware/drivers/fat.c and a couple places in apps/buffering.c -
|
||||
* reliance on it is a bug! */
|
||||
static inline void mutex_set_preempt(struct mutex *m, bool preempt)
|
||||
{ m->no_preempt = !preempt; }
|
||||
#endif
|
||||
#else
|
||||
/* Deprecated but needed for now - firmware/drivers/ata_mmc.c */
|
||||
static inline bool mutex_test(const struct mutex *m)
|
||||
{ return m->thread != NULL; }
|
||||
#endif /* HAVE_PRIORITY_SCHEDULING */
|
||||
|
||||
#ifdef HAVE_SEMAPHORE_OBJECTS
|
||||
extern void semaphore_init(struct semaphore *s, int max, int start);
|
||||
extern void semaphore_wait(struct semaphore *s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue