Skip to content
Advertisement

uninterrupted execution of Cpp Linux code

Hi is there a method on which I can make my code safe from other OS interrupts etc in Linux GNU? For example if I have the code below and I need to find the exact execution time without other things interrupting my code.

I have already looked into pthread_mutex_lock(&cs_mutex); but wasn’t able to stop other operations to run.

JavaScript

Advertisement

Answer

You can use clock_gettime:

JavaScript

It won’t prevent other processes interrupting your code but it will only time the execution of your process taking such interrupts into account.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement