Commit c47eb30
committed
Protect printf with spinlock to prevent interleaved output on SMP
On SMP systems, concurrent calls to printf() from multiple harts can
cause interleaved and unreadable output due to racing writes to the
shared output buffer.
Add a spinlock to serialize access to printf(), ensuring that only one
hart writes at a time.
This change improves the readability of debug messages and prevents
garbled output when multiple harts are active.1 parent 462d725 commit c47eb30
1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| 268 | + | |
264 | 269 | | |
265 | 270 | | |
266 | 271 | | |
| 272 | + | |
267 | 273 | | |
268 | 274 | | |
269 | 275 | | |
| |||
0 commit comments