I'm currently reading Tanenbaum's Modern Operating Systems and have a question about Gang- or Co-Scheduling:
It's stated that an Operating Systems code is divided into logical parts by Mutexes to allow different parts of the OS to be executed simultaneously on different CPU cores (e.g. the file system code can be run in parallel with the code handling interrupts). This means that the part of the OS which is responsible for the thread or process scheduling must be protected by a mutex.
Additionally it's stated that if two processes A and B are communicating heavily, the OS should use Gang- or Co-Scheduling to let these two processes be run on different cores at the same time. This is a performance improvement because both processes might otherwise be blocked by waiting for the answer of the respective other process.
Now my questions:
How does an OS schedule a process or thread on a core on which it's not currently running? E.g. the scheduler runs on core X and therefore can only switch the context to another thread on core X and not CPU/core Y.
How is the OS able to schedule multiple cores at a time? If the scheduler only runs on one core and is protected by a mutex to not run on multiple cores at a time?