开发者

Why does it take longer to call a fork() than it does to call pthread_create()?

开发者 https://www.devze.com 2023-02-10 16:17 出处:网络
I was wondering this, is it because they only need a stack and stor开发者_如何转开发age for registers so they are cheap to create ?

I was wondering this, is it because they only need a stack and stor开发者_如何转开发age for registers so they are cheap to create ?

Thanks a lot :)


fork() has to clone the entire process and all its associated kernel data structures, including file handles, memory, and so forth. Though this might be done lazily by setting appropriate copy-on-write flags, it is a lot more work than creating a new thread, which just shares the same file handles and memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消