Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Swing Thread Lock during MMIO / Display Character #209

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

javalosr2004
Copy link

Issue: Display Freeze during MMIO Output

Hi, I am opening a PR in regard to to an issue I was having when printing characters to MMIO, it would randomly freeze, the sp would always vary, so I took a look at the stack trace during program execution.

I also saw that someone else had a similar issue a couple years ago, but it was seemingly fixed: link here

Stack Trace

"RISCV" #55 [126983] prio=4 os_prio=31 cpu=389.33ms elapsed=261.90s tid=0x000000013d48c400 nid=126983 waiting for monitor entry [0x00000002fc641000]

java.lang.Thread.State: BLOCKED (on object monitor)

at java.awt.Component$AccessibleAWTComponent.getLocationOnScreen(java.desktop@21/Component.java:9802)
- waiting to lock <0x000000070042e9f0> (a java.awt.Component$AWTTreeLock)
at javax.swing.JComponent$AccessibleJComponent.getLocationOnScreen(java.desktop@21/JComponent.java:3735)
at javax.swing.text.JTextComponent$AccessibleJTextComponent.caretUpdate(java.desktop@21/JTextComponent.java:2622)
at javax.swing.text.JTextComponent.fireCaretUpdate(java.desktop@21/JTextComponent.java:408)
at javax.swing.text.JTextComponent$MutableCaretEvent.fire(java.desktop@21/JTextComponent.java:4484)
at javax.swing.text.JTextComponent$MutableCaretEvent.stateChanged(java.desktop@21/JTextComponent.java:4506)
at javax.swing.text.DefaultCaret.fireStateChanged(java.desktop@21/DefaultCaret.java:857)
at com.apple.laf.AquaCaret.fireStateChanged(java.desktop@21/AquaCaret.java:86)
at javax.swing.text.DefaultCaret.changeCaretPosition(java.desktop@21/DefaultCaret.java:1343)
at javax.swing.text.DefaultCaret.handleSetDot(java.desktop@21/DefaultCaret.java:1242)
at javax.swing.text.DefaultCaret.setDot(java.desktop@21/DefaultCaret.java:1223)
at javax.swing.text.DefaultCaret$Handler.insertUpdate(java.desktop@21/DefaultCaret.java:1819)
at javax.swing.text.AbstractDocument.fireInsertUpdate(java.desktop@21/AbstractDocument.java:227)
at javax.swing.text.AbstractDocument.handleInsertString(java.desktop@21/AbstractDocument.java:781)
at javax.swing.text.AbstractDocument.insertString(java.desktop@21/AbstractDocument.java:740)
at javax.swing.text.PlainDocument.insertString(java.desktop@21/PlainDocument.java:131)
at javax.swing.JTextArea.append(java.desktop@21/JTextArea.java:482)

**at rars.tools.KeyboardAndDisplaySimulator.displayCharacter(KeyboardAndDisplaySimulator.java:336)
at rars.tools.KeyboardAndDisplaySimulator.processRISCVUpdate(KeyboardAndDisplaySimulator.java:253)**

at rars.tools.AbstractToolAndApplication.update(AbstractToolAndApplication.java:480)
at java.util.Observable.notifyObservers(java.base@21/Observable.java:174)
at rars.riscv.hardware.Memory$MemoryObservable.notifyObserver(Memory.java:1126)
at rars.riscv.hardware.Memory.notifyAnyObservers(Memory.java:1156)
at rars.riscv.hardware.Memory.set(Memory.java:428)
at rars.riscv.hardware.Memory.setWord(Memory.java:500)
at rars.riscv.instructions.SW.store(SW.java:39)
at rars.riscv.instructions.Store.simulate(Store.java:57)
at rars.simulator.Simulator$SimThread.run(Simulator.java:484)
at java.lang.Thread.runWith(java.base@21/Thread.java:1596)
at java.lang.Thread.run(java.base@21/Thread.java:1583)

Solution

I simply used Swing's invokeLater function to queue up the display of a new character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RARS freezes when printing and reading simultaneously (Keyboard and Display MMIO Simulator)
1 participant