| Subject: |
|
Re: QSPY fail after QF::run() |
| Name: |
|
Miro Samek |
| Date Posted: |
|
Jul 2, 08 - 8:34 AM |
| Email: |
|
miro@quantum-leaps.com |
| Website: |
|
http://www.quantum-leaps.com |
| Message: |
|
The standard Linux port (included in the standard QP distribution) uses a dedicated "idleThread" to perform the QS output. Please make sure that you start that thread.
Here are the pertinent code snippets from the standard Linux port:
#ifdef Q_SPY
extern "C" void *idleThread(void *me) { // the expected P-Thread signature
for (;;) {
struct timeval timeout = { 0 }; // timeout for select()
timeout.tv_usec = 8000; // always set timeout in Linux
// sleep for the full tick or until a console input arrives, NOTE01
select(0, 0, 0, 0, &timeout);
{ // perform QS output
uint16_t nBytes = 1000;
uint8_t const *block;
QF_INT_LOCK(ignore);
block = QS::getBlock(&nBytes);
QF_INT_UNLOCK(ignore);
if (block != (uint8_t *)0) {
send(l_sock, (char const *)block, nBytes, 0);
}
}
}
return (void *)0; // return success
}
#endif
/* either in QF::onStartup() or in QS::onStartup() ...*/
. . .
pthread_t idle;
if (pthread_create(&idle, &attr, &idleThread, 0) != 0) {
// Creating the p-thread with the SCHED_FIFO policy failed.
// Most probably this application has no superuser privileges,
// so we just fall back to the default SCHED_OTHER policy
// and priority 0.
pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
param.sched_priority = 0;
pthread_attr_setschedparam(&attr, ¶m);
Q_ALLEGE(pthread_create(&idle, &attr, &idleThread, 0) == 0);
}
pthread_attr_destroy(&attr);
. . .
|
|
Replies:
|
|
|
|
|