Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
Commit3586586
committed
rp2/mpthreadport: Fix atomic section.
Prior to this commit there is a potential deadlock inmp_thread_begin_atomic_section(), when obtaining the atomic_mutex, in thefollowing situation:- main thread calls mp_thread_begin_atomic_section() (for whatever reason, doesn't matter)- the second core is running so the main thread grabs the mutex via the call mp_thread_mutex_lock(&atomic_mutex, 1), and this succeeds- before the main thread has a chance to run save_and_disable_interrupts() a USB IRQ comes in and the main thread jumps off to process this IRQ- that USB processing triggers a call to the dcd_event_handler() wrapper from commitbcbdee2- that then calls mp_sched_schedule_node()- that then attempts to obtain the atomic section, calling mp_thread_begin_atomic_section()- that call then blocks trying to obtain atomic_mutex- core0 is now deadlocked on itself, because the main thread has the mutex but the IRQ handler (which preempted the main thread) is blocked waiting for the mutex, which will never be freeThe solution in this commit is to use mutex enter/exit functions that alsoatomically disable/restore interrupts.Fixes issues#12980 and#13288.Signed-off-by: Damien George <damien@micropython.org>1 parenteadae37 commit3586586
1 file changed
+10
-9
lines changedLines changed: 10 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
45 | 46 |
| |
46 | 47 |
| |
47 | 48 |
| |
48 |
| - | |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
54 |
| - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 |
| |
56 |
| - | |
57 |
| - | |
58 | 59 |
| |
59 | 60 |
| |
60 | 61 |
| |
61 |
| - | |
62 |
| - | |
63 |
| - | |
64 |
| - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
65 | 66 |
| |
66 | 67 |
| |
67 | 68 |
| |
68 | 69 |
| |
69 | 70 |
| |
70 | 71 |
| |
71 | 72 |
| |
72 |
| - | |
| 73 | + | |
73 | 74 |
| |
74 | 75 |
| |
75 | 76 |
| |
|
0 commit comments
Comments
(0)