1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 268209e..a00f131 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -581,6 +581,7 @@ static int kinetic_callback(struct timeout *tmo)
     }

     queue_post(&button_queue, BUTTON_TOUCHSCREEN, 0);
+    thread_run_next(THREAD_ID_MAIN);
     /* stop if the velocity hit or crossed zero */
     if (!data->velocity)
     {
diff --git a/firmware/export/thread.h b/firmware/export/thread.h
index 87c2d2d..537a826 100644
--- a/firmware/export/thread.h
+++ b/firmware/export/thread.h
@@ -286,6 +286,8 @@ struct thread_entry
                                   creation or thread_set_priority) */
     unsigned char priority;    /* Scheduled priority (higher of base or
                                   all threads blocked by this one) */
+    unsigned char saved_priority; /* temoprarily saved base priority for
+                                     boosting a thread for a short time */
 #endif
     uint16_t id;               /* Current slot id */
     unsigned short stack_size; /* Size of stack in bytes */
diff --git a/firmware/thread.c b/firmware/thread.c
index 655af1a..e520beb 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -1267,6 +1267,12 @@ void switch_thread(void)
         }
     }

+    if (thread->saved_priority != 0)
+    {
+        thread_set_priority(thread->id, thread->saved_priority);
+        thread->saved_priority = 0;
+    }
+
     /* And finally give control to the next thread. */
     load_context(&thread->context);

@@ -1971,7 +1977,7 @@ int thread_set_priority(unsigned int thread_id, int priority)
     {
         int old_priority = thread->priority;

-        old_base_priority = thread->base_priority;
+        old_base_priority = thread->base_priority & 0xf;
         thread->base_priority = priority;

         prio_move_entry(&thread->pdist, old_base_priority, priority);
@@ -2098,6 +2104,18 @@ int thread_get_priority(unsigned int thread_id)

     return base_priority;
 }
+
+void thread_run_next(unsigned int thread_id)
+{
+    struct thread_entry *thread = thread_id_entry(thread_id);
+    int old_prio = thread_get_priority(thread->id);
+    if (old_prio != -1 && thread->saved_priority == 0)
+    {
+        thread_set_priority(thread->id, PRIORITY_REALTIME_1);
+        thread->saved_priority = old_prio;
+    }
+}
+
 #endif /* HAVE_PRIORITY_SCHEDULING */

 #ifdef HAVE_IO_PRIORITY