James
James

Reputation: 71

ioctl and execution time

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

Upvotes: 4

Views: 2204

Answers (1)

Paul Rubel
Paul Rubel

Reputation: 27212

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?

Upvotes: 1

Related Questions