-
threads and memory issue
i m using four threads in a c program.each thread runs in an infinite while loop but that leads to nearly 95% cpu usage.The program requirement forbids me to use sleep to pause a thread.All the threads need to run continuously.....do i have any other alternative to using infinte while loop...
-
What your program is going to do? What platform?
-
Actually its doing some calculation in each thread.....using a few array and global variables...its on linux...
-
Have your heard about semaphores or synchronization? if not just make a search! I think these are the concepts you are looking for!
Using while(1) loops (I think this is waht you did) is a performance penalty!
-
If your program has to do some heavy calculations, 95% CPU usage is natural. I concluded that your threads should run in parallel and are independent.
-
Using the sleep thing also didnt help me.....the cpu usage still exceeds 95%....do i have another alternative to using while(1)....
-
What your program is supposed to do?
Why you want it to use less CPU power?