myWallJSON
myWallJSON

Reputation: 9512

How to tall gcc that I want no more than 50% occupation per core while compiling/linking?

I wonder if it is possible having N cores on production server tall gcc that I want it to use 50% of each core while compiling/linking? Can we start gcc from some other application that would allow it to use only half of cpu?

Upvotes: 0

Views: 153

Answers (2)

Brian Johnson
Brian Johnson

Reputation: 176

gcc, like most programs, has no built-in way to slow itself down. You could write a wrapper program that spawns a subprocess, and then repeatedly uses the POSIX functions usleep and kill in a loop to stop and restart it until it finishes. However, I am wondering why you need to use each core 50% of the time, rather than using half of the cores 100% of the time -- which, as has already been pointed out, is far easier to accomplish by adjusting the number of parallel jobs make runs. For example, make -j 2 will limit the number of gcc processes to 2.

Edit: You may also be able to achieve your goal by running make with a high niceness level.

Upvotes: 1

nobody
nobody

Reputation: 20174

No, what you request is not possible.

Upvotes: 0

Related Questions