how to limit execttion time of a function
I am trying to run a compiled c program from my program
1 2 3 4 5 6 7 8 9 10 11 12
|
float execute(char filename[]){
float run_time
char str[40];
strcpy(str,".// ");
strcat(str,filename);
strcat(str," <in.txt> out.txt");
//str = ./ xyz(say) <in.txt> out.txt
system(str);
.
.
return run_time;
}
|
i want to ensure that the function terminates within 5 seconds no matter what.
but i have no idea how to ensure that
can somebody help??
You could run it in a separate thread, and outside of the thread check the time the function already ran.
i don't know how to run threads in c
can you give me some relevant links?
Google. There's a bunch of threading API's out there, though most of them are very similar to each other.
Topic archived. No new replies allowed.