> ..lots and lots of mutexes... You know, that's a bit of an
> exageration... And besides, from the diagram side of things you
> only need mutexes around controls with local variables, control
> references, and perhaps referenced property nodes. If the panel is
> open, the control values, at least, are already mutexed. From your
> statement the reader might get the impression you'd need additional
> mutexes around every front panel object in every vi throughout their
> entire application.
I'm more than happy to answer questions, but correcting these statements
does not seem to be the most productive way to go about things. But
here we go. Controls without locals can still be accessed via the
connector pane, additionally, the user can be modifying a control's data
at the same time as the diagram wishes to read it. Both of these
situations mean that a mutex is needed or control data, even with no
local, no properties. Add in the fact that the VI Server allows for
references to labels, captions, colors, fonts, and you can't even use
static analysis to determine which pieces need protection and which not.
So, the current system allows for one thread to perform all of the UI
tasks and the other threads do diagram execution. The requires a few
mutexes at the boundaries, but not as many as would be needed if other
threads were allowed in the panels. If you think I'm exagerating, fine.
I have access to the LV source code and I deal with thread access and
mutexes on a regular basis.
> Your statement "would often have only a single thread active anyhow"
> suggest that a thread is suspended by a mutex. I had actually hoped
> LV was dealing with the mutexing so that a thread wouldn't be
> suspended.
In C code, two threads approach a mutex, each getting the CPU for a
short amount of time. The first that reaches it acquires and goes past.
The second thread tries to acquire and is blocked. Ideally it is
suspended and wastes no CPU resources. The OS continues to give time to
the unsuspened threads until the thread that has the mutex gets to the
end of the protected code and releases it. Typically this is when the
OS gives the suspended thread some time to execute. A thread is simply
a stack, register values including an instruction pointer, and a bit of
other storage for things local to the thread. A thread executes one
instruction after another and has no way of jumping around. Instead,
the OS jumps around activating various threads in order to execute
different code.
The threads in LV's execution systems are no different, but the code
that the threads execute frequently return to the scheduler, where they
are given code to execute from their priority queues. When not in the
scheduler, the threads indeed get blocked and suspended at the whim of
the OS, priorities, and mutexes.
.... It was my understanding that LV4.1 used a single
> threaded prioritized queue for its diagrams and another threaded queue
> for the GUI. I assumed the threading changes you had made to
> execution environment were causing the degradation.
LV4.1, like all LV's before LV5 when threading was introduced executed
all VIs using the UI thread. There was no need for mutexes since there
was only one thread. Bad part of this was that drawing a graph or table
meant no diagram was executing. Similarly a single DLL or CIN would
bring all of LV to a halt until it returned the one and only thread to
do something else.
> ... to do with threading. The drawing performance of the table control in
> LV6.0 compared to LV4.1 just stinks. Sorry, but it does.
No need to apologize. Let's get to the bottom of this. I'm using a Mac
at home, so threading won't affect my timings at all since both LV 4.1
and 6.1 on mac are single threaded. Building strings and sending them
to a table I got times that showed that the LV6.1 does tend to be a
little slower than LV4.1 table. With some table shapes they are
virtually identical times, with other shapes I get somewhere around 50%
more time spent in 6.1. I wasn't testing any attributes/properties, so
I really don't know what your numbers are. If you will build an example
showing the performance difference and send it to NI tech support,
someone can look into it. It is likely that some feature or set of
features affected the display speed, but it could also be a bug.
> Obviously something has changed. ...I also notice the vi was using
> twice the memory in LV6.0 as LV4.1 so now I'm thinking perhaps LV6.0
> is using Unicode for the front panel display causing some of the
> degradation in performance... I really don't believe that, but you can
> have the benefit of the doubt.
I suspect the memory usage is due to the transfer data that frees the
panel and diagram up. Again, this is just a guess since I can't look at
your VI. Build something that shows the affect, send it to NI tech
support and you should get a better explanation.
And while the unicode is a good guess, LV doesn't use unicode for
display, though it does support dual byte characters. So this doesn't
explain the performance difference.
Greg McKaskle