Re: C++ fluency
On May 9, 11:52 pm, Ian Collins <ian-n...@hotmail.com> wrote:
James Kanze wrote:
On May 8, 11:15 pm, Ian Collins <ian-n...@hotmail.com> wrote:
You wrote "you have absolutely no control over when Windows
or Unix does a context switch" I provided you with an
example of how at least one of those does provide such
control.
Except that they don't. They define policies, but they
certainly don't allow you to control exactly when the
context swaps occur.
If you put a high priority real-time thread on a single core
Solaris system in a while(1) loop, you will brick the box.
The last context switch the system will make is the one that
starts your thread.
I know, I did it once!
I know that too. In 32 bit mode on a Sparc, the g++
implementation of std::string does just that (and will brick the
box, if priority inversion occurs).
But how is this relevant to debugging multithreaded code? What
I need is the possibility to create a situation where two
threads are active, and one interrupts the other immediately
after a specific machine instruction (or rather, that I can
loop, having one interrupting the other one instruction later
each time in the loop).
Jerry suggested an idea using the debugger (or the same
techniques used by the debugger). I'm not too sure how it would
work in practice---you could definitely loop, stopping one
instruction later in the thread each time, but how would you
force the OS to resume in the other thread (and not in the
thread you stopped)? And of course, this isn't the sort of test
you'd want to run each time you added a line of code, since it's
likely to be very, very slow.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34