Why is creating a new process more expensive on Windows than Linux?

后端 未结 10 712
情深已故
情深已故 2020-11-27 11:35

I\'ve heard that creating a new process on a Windows box is more expensive than on Linux. Is this true? Can somebody explain the technical reasons for why it\'s more expen

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 12:06

    Unix has a 'fork' system call which 'splits' the current process into two, and gives you a second process that is identical to the first (modulo the return from the fork call). Since the address space of the new process is already up and running this is should be cheaper than calling 'CreateProcess' in Windows and having it load the exe image, associated dlls, etc.

    In the fork case the OS can use 'copy-on-write' semantics for the memory pages associated with both new processes to ensure that each one gets their own copy of the pages they subsequently modify.

提交回复
热议问题