Hi all,
So, I'll start by stating the problem. The problem is that it is not possible to use Quickthreads on 64 bit Windows.
Basically, for sake of consistency with other platforms as well as 32 bit Windows, I need to be able to use Quickthreads as well.
So, before I begin I have a question:
What is the out of the box choice for SystemC threads on Windows platforms both 32 bit and 64 bit?
As far as I understand from the configure script, WinFibers is what will be used for Windows if MinGW is being used:
# use WinFiber on MinGW platforms
AS_CASE([${TARGET_ARCH}],
[mingw*],[QT_ARCH="none"])
Can someone please confirm this?
So, I recently had the discussion in this post https://forums.accellera.org/topic/5627-systemc-231-installation-problem-on-windows-7-with-cygwin.
I became sure that the issue is coming from Quickthreads and started trying to get it to work.
Starting from the 64 bit Linux Quickthreads source iX86_64.s, I created a new file x64.s which has the modifications necessary to fit the Windows 64 bit ABI/Calling convention.
I mostly got it to work. I, however, faced an issue related to exception handling.
The issue arises from the throw statements found in sc_thread_process.h which affect most of sync/async reset flows:
case THROW_SYNC_RESET:
DEBUG_MSG( DEBUG_NAME , this, "throwing reset for");
if ( m_reset_event_p ) m_reset_event_p->notify();
throw sc_unwind_exception( this, true );
...
case THROW_KILL:
DEBUG_MSG( DEBUG_NAME, this, "throwing kill for");
throw sc_unwind_exception( this, false );
I am using MinGW GCC 7.4.0 with SEH exceptions. The throw statements up there end up calling RaiseException which is a Windows API that then causes the crash. I have spent days debugging that part and I was not able to figure it out.
I need to use SEH exceptions instead of SJLJ exceptions. Reason being, that SJLJ exceptions while it works with additions in sc_cor_qt similar to those in sc_cor_fibers, side effects exist such as having an incomplete backtrace in case we're in a try block.
So, I went ahead and created a commit here https://github.com/moayman/systemc/commit/e3790038752753bbbc2b0f30c064faae058ff227 that you may want to check out. A note about my commit:
I started from SystemC 2.3.2 as I had a problem compiling 2.3.4 due to sc_mutex/sc_host_mutex
I would really appreciate any kind of help with this issue. We're so close to having Quickthreads support for 64 bit of Windows.
Thanks a lot.