[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] A great thing for when you just can't say no to W
Re: [Discuss-gnuradio] A great thing for when you just can't say no to WinBLOWS
Sun, 20 Feb 2005 09:47:25 -0800
On Sun, Feb 20, 2005 at 03:25:40PM -0000, Robert McGwier wrote:
> I have just moved all of my software defined radio code
> away from the HORRID ABOMINATION that is Windows threading
> to posix threads.
> The heart of the matter for real time code is that semaphores,
> mutexes, and threads are objects that are visible to all
> processes in winBLOWS. When you release a semaphore in
> WinBLOWS, it goes out and sees if ANY process has that
> object open and is waiting for it. On the other hand
> Critical Sections are strictly local and cannot be shared
> across processes (and why would you want to?). This is
> the one thing that Windows did right for "real timers".
> So by judicious use of flags, counters, and critical
> sections, cygwin and now redhat officially have worked
> out posix threading for Windows and it has matured enough
> for me to use it. No longer needing ming, I tried it.
> WOW. A sem_wait is OVER ONE HUNDRED TIMES faster than
> a WaitForSingleObject in my code.
Not bad ;-) If you're running under GNU/Linux 2.6 (or some versions of
Redhat under 2.4) you've got the NPTL (Native Posix Thread Library)
which really smokes. The fast path is all in user-mode. It also
works across processes if you allocate the synchronization primitives
in shared memory. (Wouldn't surprise me if the same folks did the
work on both).
If you haven't already, you may want to look at the omnithread library.
It's a thin C++ wrapper on top of both posix and NT threads. Makes
them a little handier to use from C++.
Docs are at gnuradio-core/doc/other/omnithread.pdf
Code's at gnuradio-core/src/lib/omnithread/*