Skip Nav
Home » Forums » SystemC Forum

Icon - KMLM List KMLM List

View email archives for the history of this mailing list.

List Home All Archives Dates Threads Authors Subjects
systemc-forum - RE: [Systemc-forum] Quickthreads problems on Linux platform using Pthrea Message Thread: Previous | Next
  • To: "Carey, Patrick" <patrick.carey@xxxxxxxxx>, <systemc-forum@xxxxxxxxxxx>
  • From: "Jyoti Swarup" <jyoti.swarup@xxxxxxxxxxxxxxxxx>
  • Date: Fri, 6 Feb 2004 10:21:51 +0530
Send Email to systemc-forum@osci.kavi.com:
Send new message
Reply to this message
Patrick,

 

The SystemC implementation we have is a TCL addin. It models SoC having

over 300 sc_modules, 1000 sc_signals, 100 SC_THREAD and about 20
SC_METHODS.

TCL is used to instantiate the system and run it over a spawned
pthread/winthread.

It certainly has a lot of allocations and deallocation during
simulations with active 

TCL console. The simulation is controlled from TCL using semaphore in
both Windows/Linux 

environment. The threads protect their critical regions using
CRITICAL_SECTION/

pthread_mutex_t. The implementation is being used actively for
software-development 

and we do not have any issue to be concerned about.

 

The environment we have is VC7/gcc2.96 [ Rh7.2]. The default libc with
gcc2.96 is 

Thread-safe [ for most practical application].

 

I suggest you try out a simple sample application, and get it working [
or demonstrate

the problem]. We could take it further from there.

 

Regards,

~Jyoti

 

 

-----Original Message-----
From: Carey, Patrick [mailto:patrick.carey@xxxxxxxxx] 
Sent: Friday, February 06, 2004 6:21 AM
To: Jyoti Swarup; systemc-forum@xxxxxxxxxxx
Subject: RE: [Systemc-forum] Quickthreads problems on Linux platform
using Pthreads

 

Thanks for the information.  The problem isn't that the threads don't
run, it is that if you do a "new" call and try to allocate memory, you
will get a seg fault in malloc.  So basically, you can't allocate memory
in a SC_THREAD running on top of a Pthread (linuxthread).  This was
confirmed a few years ago in a Systemc-forum message and also with work
we did in the last few months.  I will try the "stp_init" call and maybe
that will work. 

 

Patrick

 

 

-----Original Message-----
From: systemc-forum-admin@xxxxxxxxxxxxxxxxxxx
[mailto:systemc-forum-admin@xxxxxxxxxxxxxxxxxxx] On Behalf Of Jyoti
Swarup
Sent: Thursday, February 05, 2004 2:02 AM
To: systemc-forum@xxxxxxxxxxx
Subject: RE: [Systemc-forum] Quickthreads problems on Linux platform
using Pthreads

Hi,

We have SystemC simulations with SC_THREADs running pretty well on
spawned

threads in both pthread and winthreads environment. 

 

Regards,

~Jyoti

 

-----Original Message-----
From: Jyoti Swarup 
Sent: Thursday, February 05, 2004 11:00 AM
To: systemc-forum@xxxxxxxxxxx
Subject: RE: [Systemc-forum] Quickthreads problems on Linux platform
using Pthreads

 

Some more inputs to your problems.  

 

We run the simulations in the main thread. 

You might face problems if you run the simulations in other [ spawned]
threads.

The reason for this is that SC_THREADs are cooperative multitasking
constructs 

called coroutines. The co-routines are generally implemented by
libraries, using 

setjump and longjmp and stack-preserving techniques. 

SystemC uses Qt on linux and Fibers on Windows [native]. To use these
libraries

You would first need to initialize it the thread you are going to
construct co-routines.

In windows, SystemC does it kernel/sc_cor_fiber.cpp with call with
ConvertThreadToFiber().

Similar, initialization would be required linux there is a function
called stp_init In qt library,

but SystemC does not seem to be using it. [ ref:

http://www.cs.washington.edu/research/compiler/papers.d/quickthreads.htm
l ]

 

Your problems could be fixed by either,

1)       Running the simulations on the main thread. Or

2)       Calling stp_init on the spawned threads [ I am not too sure]

 

Hope it helps..

 

Regards,

 

~Jyoti

 

-----Original Message-----
From: Jyoti Swarup 
Sent: Thursday, February 05, 2004 9:43 AM
To: Carey, Patrick; systemc-forum@xxxxxxxxxxx
Subject: RE: [Systemc-forum] Quickthreads problems on Linux platform
using Pthreads

 

We have an implementation which we run simulation from one pthread, with
lots of SC_THREADS

And control and peek simulation from another threads. We do not face any
problem.

May be you have some memory corruption issue or not locking mutual
data-structure using mutexes.

 

~Jyoti

 

-----Original Message-----
From: Carey, Patrick [mailto:patrick.carey@xxxxxxxxx] 
Sent: Wednesday, February 04, 2004 10:10 PM
To: systemc-forum@xxxxxxxxxxx
Subject: [Systemc-forum] Quickthreads problems on Linux platform using
Pthreads

 

 

Has anyone had any success in getting SystemC threads (SC_THREADS) to
work on top of a system running Pthreads on Linux?  I know from the past
few years that there was an issue with the Linux Pthread library in its
handling of certain pointers on the stack that causes errors with
malloc.  We have a validation system where the base executable is
running Pthreads and this program kicks off other tools, one of which is
a SystemC design that has test threads in it.  The test threads seg
fault with malloc due to the incompatibility described above.  Does
anyone know if it is possible to reimplement the Pthreads library or any
other workaround so these two thread systems can coexist?

Thanks, 
Patrick Carey 


By Date: Previous | Next Current Thread By Thread: Previous | Next

  Mail converted by the most-excellent MHonArc 2.6.10