CGroup

    Allow to balance resources (cpy, memory, others) per user, group of processes, and so on

    Require cgroup-tools package

    Example

    cgcreate -g cpu:/cpulimited # cpulimited is a path
    cgset -r cpu.shares=1024 cpulimited
    cgexec -g cpu:cpulimited dd if=/dev/zero of=/dev/null &
    cgexec -g cpu:cpulimited dd if=/dev/zero of=/dev/null &
    

    Note: If you got a computer with one CPU, it will give 50% of the cpu for each process (2 dd commands). If you got 2 CPU, each command will use a CPU. If you got more than 2 CPU let say 3 and the command is able to be parallelized (thread or process), one of them will use 1 CPU, and the other 2 CPUs. In case another process (without cgroup) start, the two dd commands will give priority to the started process having no cgroup.

    cgcreate -g cpu:/lesscpulimited
    cgset -r cpu.shares=512 cpulimited
    cgexec -g cpu:cpulimited dd if=/dev/zero of=/dev/null & # Note here it's cpulimited
    cgexec -g cpu:lesscpulimited dd if=/dev/zero of=/dev/null & # # here it's lesscpulimited
    

    Note: If you got a computer with one CPU, the dd from cpulimited will get 66% and the dd from lesscpulimited will get 33% of the CPU.

    Source