NOTE. . To understand my question, you may need to find out about my project and problem. If not, skip directly to the “QUESTION” section below.
< / "> Project
I am working on writing a C ++ class that allows its parents to act as synchronous / blocking threads using Pause () and Resume ().
Here is an example of how this will work.
class BlockingThread
: public BlockingThreadBase
{
void StartStopHere(void)
{
printf("1"); Pause();
printf("3"); Pause();
printf("5"); Pause();
}
};
int main(void)
{
BlockingThread obj;
obj.Resume(); printf("2");
obj.Resume(); printf("4");
obj.Resume(); printf("6");
return 0;
}
I tried a real thread and some new ideas, but they were too slow to switch between codes 21 million times per second.
- ( ), . obj1.Resume(), , New #1 Stack, Pause(), , .
</" > < >
- BlockingThread main().
_________________
| Normal | Stack |
| Stack | Buffer |
|________|________|
BlockingThread main() .
___________________________________
| Normal | Stack | New #1 | Stack |
| Stack | Buffer | Stack | Buffer |
|________|________|________|________|
BlockingThread main() .
_____________________________________________________
| Normal | Stack | New #1 | Stack | New #2 | Stack |
| Stack | Buffer | Stack | Buffer | Stack | Buffer |
|________|________|________|________|________|________|
</" >
"" , obj.Resume() ( ), , , StartStopHere(), segfault StartStopHere(). GDB can't find linker symbol for virtual table for 'BlockingThreadBase' value, - BlockingThreadBase. , StartStopHere() .
</" >
( , )
[ ] vtable ( , , ) [] [ ]?