开发者

ioctl and execution time

开发者 https://www.devze.com 2023-01-16 16:41 出处:网络
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:

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 var开发者_开发知识库iables now since it increases the time taken, cant keep them either - will get killed in code review :)

Kindly let me know

Thanks


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消