Commit de11dde
committed
Implement event-driven UART coroutine
This fixes boot failure and CPU spinning issues in SMP mode through
hybrid polling strategy that dynamically switches between blocking and
non-blocking modes based on hart activity.
1. Event loop optimization
- Observe hart states BEFORE resuming them
- Set poll_timeout = -1 when all harts idle (event-driven)
- Set poll_timeout = 0 when harts have work (polling)
- Always resume harts unconditionally (avoid deadlock)
2. UART coroutine support
- Hart yields when no stdin data available
- Event loop resumes hart when stdin becomes readable
- Spurious wakeup handling with state re-check
3. Coroutine state tracking
- waiting_hart_id tracks which hart is waiting for UART
- has_waiting_hart enables quick idle state check
- Sentinel value (UINT32_MAX) for single-core fallback1 parent 4552c62 commit de11dde
4 files changed
+73
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
610 | 614 | | |
611 | 615 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
| 772 | + | |
771 | 773 | | |
772 | 774 | | |
773 | 775 | | |
| |||
1177 | 1179 | | |
1178 | 1180 | | |
1179 | 1181 | | |
1180 | | - | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
1181 | 1185 | | |
1182 | | - | |
| 1186 | + | |
1183 | 1187 | | |
1184 | 1188 | | |
1185 | 1189 | | |
1186 | 1190 | | |
1187 | | - | |
| 1191 | + | |
1188 | 1192 | | |
1189 | 1193 | | |
1190 | 1194 | | |
1191 | | - | |
1192 | | - | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1193 | 1201 | | |
1194 | 1202 | | |
1195 | | - | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1196 | 1207 | | |
1197 | | - | |
1198 | | - | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
1199 | 1213 | | |
1200 | 1214 | | |
1201 | | - | |
1202 | | - | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1203 | 1218 | | |
1204 | 1219 | | |
1205 | 1220 | | |
| |||
1231 | 1246 | | |
1232 | 1247 | | |
1233 | 1248 | | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1234 | 1254 | | |
1235 | 1255 | | |
1236 | 1256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
89 | 116 | | |
90 | 117 | | |
91 | 118 | | |
92 | 119 | | |
93 | | - | |
94 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
95 | 129 | | |
96 | 130 | | |
97 | 131 | | |
| |||
0 commit comments