summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bf51520)
Cortex-M0 parts don't have a hardware divide, so doing a modulus
to compute task hash indexes is super slow. Avoid that by making the sleep
queue a power of two.
Signed-off-by: Keith Packard <keithp@keithp.com>
#endif
#ifndef SLEEP_HASH_SIZE
#endif
#ifndef SLEEP_HASH_SIZE
+#ifdef __ARM_FEATURE_IDIV__
#define SLEEP_HASH_SIZE 17
#define SLEEP_HASH_SIZE 17
+#else
+#define SLEEP_HASH_SIZE 16
+#endif
+#endif
+
+#if SLEEP_HASH_SIZE & (SLEEP_HASH_SIZE - 1)
+#define SLEEP_HASH_SHIFT 0
+#else
+#define SLEEP_HASH_SHIFT 2
#endif
static struct ao_list run_queue;
#endif
static struct ao_list run_queue;
static struct ao_list *
ao_task_sleep_queue(void *wchan)
{
static struct ao_list *
ao_task_sleep_queue(void *wchan)
{
- return &ao_sleep_queue[(uintptr_t) wchan % SLEEP_HASH_SIZE];
+ return &ao_sleep_queue[(((uintptr_t) wchan) >> SLEEP_HASH_SHIFT) % SLEEP_HASH_SIZE];