0

Really odd question I know. It's to help demonstrate my university coursework. I'm going to be killing processes that are using more than 10% of the CPU.

1
  • Do you want 100% of a single logical core, or the entire CPU? Prime95 and other typical CPU benchmarking/stresstesting programs tend to be useful for these purposes.
    – Bob
    Commented Apr 18, 2014 at 14:14

1 Answer 1

1

I wrote the following super-simple C program some time ago to test scheduling algorithms, should work for you as well:

#include <stdio.h>
#include <stdlib.h>

void main()
{
  while(1==1)
    {
      int a = 400;
      a * 400;
    }
}

Compile with gcc -o executable_name c_source_file.c and run with ./executable_name. This should give you a single process with 100% cpu usage.

2
  • Note: this would be a single thread, therefore at most it can use 100% of a single logical core. Some tools will report this as 100% per core, others report it as 100% overall (so 12.5% for a single core, if you had 8 logical cores).
    – Bob
    Commented Apr 18, 2014 at 14:13
  • 1
    @Bob, true. I also wrote a multithreaded version, but it'll only work on Solaris: pastebin.com/enJfLR2L
    – mtak
    Commented Apr 18, 2014 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .