Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How in c we get data every time from ram for slow execution.Is there any method in c Language we miss the Cache Every time.I want to Execute my program as slow as possible

What I have tried:

for(int i=0;i>0;i++)
{
//slow code here
}
Posted
Updated 26-Aug-17 3:50am
v2
Comments
Patrice T 26-Aug-17 6:24am    
Looks like a bad solution to another problem.
Can you explain what problem you try to solve ?
Member 12107284 26-Aug-17 7:23am    
sir i want to slowly execute a c program and i use timer which tell me time for execution.I am failed to get the data from Ram always get data form cache
Patrice T 26-Aug-17 9:59am    
Something makes you think that data from RAM is different from data of cache ?

1 solution

Quote:
I want to Execute my program as slow as possible
Why? That's a pretty esoteric request...

If you want to force a slow execution, the only practical way is to use the operating system to slow your thread down by putting the task to sleep, either inside your loop or instead of it. Exactly how you do that we can't say, because it will vary from target system to system - but start by looking for "sleep" in the library documentation for your compiler / IDE.
 
Share this answer
 
Comments
Member 12107284 26-Aug-17 6:30am    
Sir There is no any method to skip the cache in c. I want to miss cache.
OriginalGriff 26-Aug-17 6:54am    
No. Even if there was, which cache? Modern processors have Level 1 and Level 2 caches, Windows maintains caches, hard drives have caches.

And we have no idea what system your code is even going to be run on - any cache you could disable would depend on the exact OS, Version, and specific hardware your code is running on, as well as the compiler / libraries you are using.

Why do you think this would be a good idea?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900