Suppose there is a root process (R) that can create a subprocess (S). S can create its own subprocesses (s1, s2, ...). R can set the CPU affinity of S during S's creation. However, I don't want S to modify its CPU affinity or break the CPU affinity when creating its own subprocesses.
For example, R may set S to use CPU 1-10 to run itself. S may modify it, but it cannot use CPU cores that greater than 10. And when S create s1, s2..., it cannot assign CPU cores other than 1-10 to them.
I can control R's logic but I cannot control the logic of S, s1, s2... Are there anyway to force S and its subprocesses to use specific CPU cores when R creating S?
Add more info as Charles Duffy said "there are lots of different ways to do this, and there's not enough details present in the question to be able to disqualify any of them."
- The OS is Ubuntu 18.04 / 20.04
- You can consider R as a bash script and S should be created inside it.
With the above info, are there any demo that can shows a way to do that?