Subject: Re: [vhdl-200x] RE: Posix Threads
From: Evan Lavelle (eml@riverside-machines.com)
Date: Wed Jun 11 2003 - 23:54:04 PDT
vhdl-200x@grfx.com wrote:
> (snipped)
I think I probably didn't make my point clearly enough. What I was
trying to say was:
1 For the simple case which is supported by V95, 'fork/join' is far
more concise and expressive than any pthreads solution. This is what my
code fragments were intended to show. There are clearly more complex
cases which can't be handled by fork/join, but that wasn't my point.
2 If we were to provide a standard calling interface to C code, then
pthreads would come for free anyway. It doesn't need any language support.
3 If we were instead to provide a standard calling interface to C++,
then we would get the standard C++ library, including the STL, for free,
and this is far more useful, on a day to day basis, than pthreads. We'd
also get pthreads, possibly with a bit of extra work, since it has C
linkage. I'm sure there are complications here I haven't thought about,
but they should be resolvable.
Additionally:
> Since pthreads is just an API it would leave the VHDL simulator vendors
> free to implement efficient implementations, if they want to just use
> the standard C pthreads library that would be an option. HDLs tend to
A simulator vendor is the wrong person to provide a pthreads library -
it needs to come from the OS vendor. Look up Drepper & Molnar's paper
'The Native Posix Thread Library for Linux' for some background
(<people.redhat.com/drepper/nptl-design.pdf>).
> have a much higher number of threads than C programs so OS based
> mechanisms for mutexes and thread context switching tend to be too
> inefficient (SystemC's problem).
As an aside, SystemC doesn't specify how the scheduler is implemented.
The reference OSCI implementation is a normal
single-process/single-thread app; it doesn't use threads. Using threads
for HDL processes would be bizarre; it would be far too expensive
(particularly on Linux, where a thread is actually a process). If you
have the OSCI sources, you can find the evaluate/update code in the
'crunch' routine in sc_simcontext.cpp.
Evan
This archive was generated by hypermail 2b28 : Wed Jun 11 2003 - 23:56:32 PDT