views:

89

answers:

1

Hi,

I have a program running two threads - they communicate using message queues.

In one thread, I call ioctl() to access the hardware decryptor. The code goes like:

void Decrypt
{

...
..
...

if(<condition 1>)
{.
...
...
retVal = ioctl(...);
comesInHere1++;
}

if(<condition 2>)
{
...
...
retVal = ioctl(...);
comesInHere2++;
}

comesInHere1 and comesInHere2 are used to count the number of times it goes in that particular if loop.

The entire program takes 80 ms to execute. But if I comment out the test variables (comesInHere1, comesInHere2 within the if loops), the execution time increases by 8 ms to 88 ms!

How is that possible? I cant comment out the variables now since it increases the time taken, cant keep them either - will get killed in code review :)

Kindly let me know

Thanks

+1  A: 

Cache? It's possible that by adding a bit more data you're moving code to different cache lines that would somehow be placed together, causing thrashing. You could experiment by running on different systems and by adding padding data between variables that are used exclusively in each thread.

What happens if you serialize the processing onto a single core?

Paul Rubel