summaryrefslogtreecommitdiff
path: root/firmware/export/kernel.h
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2010-12-26 05:59:39 +0000
committerMichael Sevakis <jethead71@rockbox.org>2010-12-26 05:59:39 +0000
commitf387cdef2131b2a0956ee8e4ff7221d3251b8f46 (patch)
tree00b9226241ecb83e8c92798241bb14ebcf5b6fab /firmware/export/kernel.h
parent1d460b603fded79cb879704a4d30a50318263211 (diff)
downloadrockbox-f387cdef2131b2a0956ee8e4ff7221d3251b8f46.tar.gz
rockbox-f387cdef2131b2a0956ee8e4ff7221d3251b8f46.zip
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
Diffstat (limited to 'firmware/export/kernel.h')
-rw-r--r--firmware/export/kernel.h19
1 files changed, 14 insertions, 5 deletions
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
142struct mutex 142struct mutex
143{ 143{
144 struct thread_entry *queue; /* waiter list */ 144 struct thread_entry *queue; /* waiter list */
145 int count; /* lock owner recursion count */ 145 int recursion; /* lock owner recursion count */
146#ifdef HAVE_PRIORITY_SCHEDULING 146#ifdef HAVE_PRIORITY_SCHEDULING
147 struct blocker blocker; /* priority inheritance info 147 struct blocker blocker; /* priority inheritance info
148 for waiters */ 148 for waiters */
149 bool no_preempt; /* don't allow higher-priority thread 149 bool no_preempt; /* don't allow higher-priority thread
150 to be scheduled even if woken */ 150 to be scheduled even if woken */
151#else 151#else
152 struct thread_entry *thread; 152 struct thread_entry *thread; /* Indicates owner thread - an owner
153 implies a locked state - same goes
154 for priority scheduling
155 (in blocker struct for that) */
153#endif 156#endif
154 IF_COP( struct corelock cl; ) /* multiprocessor sync */ 157 IF_COP( struct corelock cl; ) /* multiprocessor sync */
155 bool locked; /* locked semaphore */
156}; 158};
157 159
158#ifdef HAVE_SEMAPHORE_OBJECTS 160#ifdef HAVE_SEMAPHORE_OBJECTS
@@ -265,10 +267,17 @@ extern void mutex_init(struct mutex *m);
265extern void mutex_lock(struct mutex *m); 267extern void mutex_lock(struct mutex *m);
266extern void mutex_unlock(struct mutex *m); 268extern void mutex_unlock(struct mutex *m);
267#ifdef HAVE_PRIORITY_SCHEDULING 269#ifdef HAVE_PRIORITY_SCHEDULING
268/* Temporary function to disable mutex preempting a thread on unlock */ 270/* Deprecated temporary function to disable mutex preempting a thread on
271 * unlock - firmware/drivers/fat.c and a couple places in apps/buffering.c -
272 * reliance on it is a bug! */
269static inline void mutex_set_preempt(struct mutex *m, bool preempt) 273static inline void mutex_set_preempt(struct mutex *m, bool preempt)
270 { m->no_preempt = !preempt; } 274 { m->no_preempt = !preempt; }
271#endif 275#else
276/* Deprecated but needed for now - firmware/drivers/ata_mmc.c */
277static inline bool mutex_test(const struct mutex *m)
278 { return m->thread != NULL; }
279#endif /* HAVE_PRIORITY_SCHEDULING */
280
272#ifdef HAVE_SEMAPHORE_OBJECTS 281#ifdef HAVE_SEMAPHORE_OBJECTS
273extern void semaphore_init(struct semaphore *s, int max, int start); 282extern void semaphore_init(struct semaphore *s, int max, int start);
274extern void semaphore_wait(struct semaphore *s); 283extern void semaphore_wait(struct semaphore *s);