summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-03-09 08:03:18 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-03-09 08:03:18 +0000
commitdee43ece2086e15894934b754e47cb7ce5882cda (patch)
tree9238a5c80fe4382975387ec90eca61bda8d4ed8f /firmware/export
parentf4b83e68594f076cdfe510cd2e23b7f57fd158b5 (diff)
downloadrockbox-dee43ece2086e15894934b754e47cb7ce5882cda.tar.gz
rockbox-dee43ece2086e15894934b754e47cb7ce5882cda.zip
Put an end to priority inversion in the ata driver. Gave up trying to have fully atomic dual use mutexes so just replaced the ata driver locking with spins. Maybe I'll have better luck later. Things should run smoothly with database updates and such happening in the background.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12688 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/kernel.h10
-rw-r--r--firmware/export/thread.h14
2 files changed, 22 insertions, 2 deletions
diff --git a/firmware/export/kernel.h b/firmware/export/kernel.h
index ec8aa28a08..495e558175 100644
--- a/firmware/export/kernel.h
+++ b/firmware/export/kernel.h
@@ -83,10 +83,14 @@ struct event_queue
83#endif 83#endif
84}; 84};
85 85
86#define MTX_UNOWNED 0x00000000
87#define MTX_BLOCKED_WAITER 0x00000001
88#define MTX_SPIN_WAITER 0x00010001
89#define MTX_SPIN_OWNER 0x00020001
86struct mutex 90struct mutex
87{ 91{
92 uint32_t locked;
88 struct thread_entry *thread; 93 struct thread_entry *thread;
89 bool locked;
90}; 94};
91 95
92/* global tick variable */ 96/* global tick variable */
@@ -126,8 +130,12 @@ extern void queue_remove_from_head(struct event_queue *q, long id);
126extern int queue_broadcast(long id, intptr_t data); 130extern int queue_broadcast(long id, intptr_t data);
127 131
128extern void mutex_init(struct mutex *m); 132extern void mutex_init(struct mutex *m);
133static inline void spinlock_init(struct mutex *m)
134{ mutex_init(m); } /* Same thing for now */
129extern void mutex_lock(struct mutex *m); 135extern void mutex_lock(struct mutex *m);
130extern void mutex_unlock(struct mutex *m); 136extern void mutex_unlock(struct mutex *m);
137extern void spinlock_lock(struct mutex *m);
138extern void spinlock_unlock(struct mutex *m);
131extern void tick_start(unsigned int interval_in_ms); 139extern void tick_start(unsigned int interval_in_ms);
132 140
133#define IS_SYSEVENT(ev) ((ev & SYS_EVENT) == SYS_EVENT) 141#define IS_SYSEVENT(ev) ((ev & SYS_EVENT) == SYS_EVENT)
diff --git a/firmware/export/thread.h b/firmware/export/thread.h
index 3a979722b9..7a9414c79f 100644
--- a/firmware/export/thread.h
+++ b/firmware/export/thread.h
@@ -105,6 +105,7 @@ struct thread_entry {
105 unsigned short stack_size; 105 unsigned short stack_size;
106#ifdef HAVE_PRIORITY_SCHEDULING 106#ifdef HAVE_PRIORITY_SCHEDULING
107 unsigned short priority; 107 unsigned short priority;
108 unsigned long priority_x;
108 long last_run; 109 long last_run;
109#endif 110#endif
110 struct thread_entry *next, *prev; 111 struct thread_entry *next, *prev;
@@ -114,6 +115,10 @@ struct core_entry {
114 struct thread_entry threads[MAXTHREADS]; 115 struct thread_entry threads[MAXTHREADS];
115 struct thread_entry *running; 116 struct thread_entry *running;
116 struct thread_entry *sleeping; 117 struct thread_entry *sleeping;
118#ifdef HAVE_EXTENDED_MESSAGING_AND_NAME
119 int switch_to_irq_level;
120 #define STAY_IRQ_LEVEL -1
121#endif
117}; 122};
118 123
119#ifdef HAVE_PRIORITY_SCHEDULING 124#ifdef HAVE_PRIORITY_SCHEDULING
@@ -149,7 +154,14 @@ void wakeup_thread(struct thread_entry **thread);
149#ifdef HAVE_PRIORITY_SCHEDULING 154#ifdef HAVE_PRIORITY_SCHEDULING
150int thread_set_priority(struct thread_entry *thread, int priority); 155int thread_set_priority(struct thread_entry *thread, int priority);
151int thread_get_priority(struct thread_entry *thread); 156int thread_get_priority(struct thread_entry *thread);
152#endif 157/* Yield that guarantees thread execution once per round regardless of
158 thread's scheduler priority - basically a transient realtime boost
159 without altering the scheduler's thread precedence. */
160void priority_yield(void);
161#else
162static inline void priority_yield(void)
163 { yield(); }
164#endif /* HAVE_PRIORITY_SCHEDULING */
153struct thread_entry * thread_get_current(void); 165struct thread_entry * thread_get_current(void);
154void init_threads(void); 166void init_threads(void);
155int thread_stack_usage(const struct thread_entry *thread); 167int thread_stack_usage(const struct thread_entry *thread);