- Mastering Linux Kernel Development
- Raghu Bharadwaj
- 242字
- 2021-07-08 09:47:18
fork()
Fork() is one of the core "Unix thread APIs" available across *nix systems since the inception of legacy Unix releases. Aptly named, it forks a new process from a running process. When fork() succeeds, the new process is created (referred to as child) by duplicating the caller's address space and task structure. On return from fork(), both caller (parent) and new process (child) resume executing instructions from the same code segment which was duplicated under copy-on-write. Fork() is perhaps the only API that enters kernel mode in the context of caller process, and on success returns to user mode in the context of both caller and child (new process).
Most resource entries of the parent's task structure such as memory descriptor, file descriptor table, signal descriptors, and scheduling attributes are inherited by the child, except for a few attributes such as memory locks, pending signals, active timers, and file record locks (for the full list of exceptions, refer to the fork(2) man page). A child process is assigned a unique pid and will refer to its parent's pid through the ppid field of its task structure; the child’s resource utilization and processor usage entries are reset to zero.
The parent process updates itself about the child’s state using the wait() system call and normally waits for the termination of the child process. Failing to call wait(), the child may terminate and be pushed into a zombie state.
- Designing Machine Learning Systems with Python
- Developing Middleware in Java EE 8
- 區(qū)塊鏈:以太坊DApp開發(fā)實戰(zhàn)
- Implementing Cisco Networking Solutions
- Python Network Programming Cookbook(Second Edition)
- 小程序開發(fā)原理與實戰(zhàn)
- C程序設(shè)計實踐教程
- BIM概論及Revit精講
- C專家編程
- 軟件測試綜合技術(shù)
- Django Design Patterns and Best Practices
- 邊玩邊學(xué)Scratch3.0少兒趣味編程
- UML基礎(chǔ)與Rose建模實用教程(第三版)
- Moodle 3.x Developer's Guide
- Visual C++程序開發(fā)范例寶典