From f387cdef2131b2a0956ee8e4ff7221d3251b8f46 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 26 Dec 2010 05:59:39 +0000 Subject: 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 --- firmware/export/kernel.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'firmware/export/kernel.h') diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h index 405f6b6838..c7fcd93284 100644 --- a/firmware/export/kernel.h +++ b/firmware/export/kernel.h @@ -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); -- cgit v1.2.3