Commit 34fdc56
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 8863bcb commit 34fdc56
1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
899 | 903 | | |
900 | 904 | | |
901 | 905 | | |
902 | 906 | | |
903 | 907 | | |
904 | 908 | | |
| 909 | + | |
905 | 910 | | |
906 | 911 | | |
907 | 912 | | |
| 913 | + | |
908 | 914 | | |
909 | 915 | | |
910 | 916 | | |
| |||
0 commit comments