Simplify duplicate code
Move externs to header file
task/cgroup make TaskAffinity=hard bind to threads instead of cores.