# Does exec cause a context switch?

If we start a new process with

exec('process-2')


Does this cause an immediate context switch in order to halt the current process and then start the new 'process-2'?

Edit: This is a theoretical question with no specific OS intended, but you suppose it's some UNIX like OS.

There is no specific details about exec, the only thing I know is that exec halts the current program execution and executes the other program.

Also the assumption here is that we are using a uni processor system.

• (What does the specification say about exec()? What about a multi-processor environment?) – greybeard Nov 19 '19 at 22:35
• What OS are you on? – ghellquist Nov 21 '19 at 16:12