diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/kernel.h | 10 | ||||
-rw-r--r-- | firmware/export/thread.h | 14 |
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 | ||
86 | struct mutex | 90 | struct 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); | |||
126 | extern int queue_broadcast(long id, intptr_t data); | 130 | extern int queue_broadcast(long id, intptr_t data); |
127 | 131 | ||
128 | extern void mutex_init(struct mutex *m); | 132 | extern void mutex_init(struct mutex *m); |
133 | static inline void spinlock_init(struct mutex *m) | ||
134 | { mutex_init(m); } /* Same thing for now */ | ||
129 | extern void mutex_lock(struct mutex *m); | 135 | extern void mutex_lock(struct mutex *m); |
130 | extern void mutex_unlock(struct mutex *m); | 136 | extern void mutex_unlock(struct mutex *m); |
137 | extern void spinlock_lock(struct mutex *m); | ||
138 | extern void spinlock_unlock(struct mutex *m); | ||
131 | extern void tick_start(unsigned int interval_in_ms); | 139 | extern 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 |
150 | int thread_set_priority(struct thread_entry *thread, int priority); | 155 | int thread_set_priority(struct thread_entry *thread, int priority); |
151 | int thread_get_priority(struct thread_entry *thread); | 156 | int 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. */ | ||
160 | void priority_yield(void); | ||
161 | #else | ||
162 | static inline void priority_yield(void) | ||
163 | { yield(); } | ||
164 | #endif /* HAVE_PRIORITY_SCHEDULING */ | ||
153 | struct thread_entry * thread_get_current(void); | 165 | struct thread_entry * thread_get_current(void); |
154 | void init_threads(void); | 166 | void init_threads(void); |
155 | int thread_stack_usage(const struct thread_entry *thread); | 167 | int thread_stack_usage(const struct thread_entry *thread); |