robotdotnet / WPILib

DotNet implementation of WPILib for FIRST Robotics Competition (FRC)
27 stars 8 forks source link

Interrupts and Notifiers are broken still #91

Closed ThadHouse closed 8 years ago

ThadHouse commented 8 years ago

We might just have to forcefully disable notifiers and interrupts. I've been able to debug this issue more. What's happening is the GC is running, and trying to suspend all the threads. However, its having trouble suspending the notifier thread since that is generated by the FPGA, and the code then halts, waiting for the thread to stop before the GC runs. I have an Idea on how to solve this, but its probably going to require a native shim.

ThadHouse commented 8 years ago

So turns out I did have to do a native shim. The GC issue is exactly what was happening. So I did what the JNI now does, and gave each notifier and interrupt its own thread created with std::thread. That way, Mono can suspend it properly, and the GC doesnt crash anymore. All of the code comes from the official JNI, and I implemented it with a patch to the HAL. I attempted a seperate library shim, however that was too difficult to implement properly. The code for the shim is in the HAL\AthenaHAL\Native folder. The HAL doesnt change too often, so it should not have to be recompiled often.

ThadHouse commented 8 years ago

What helps is we have the unit test to check and make sure all the proper symbols exist, so if someone places a HAL without the shim in the library, unit testing will start failing.