In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what the fork function refers to. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Fork is a bifurcation function in UNIX or UNIX-like. The fork function divides a running program into two (almost) identical processes, each starting a thread that starts from the same place in the code. Threads in both processes continue to execute as if two users had started two copies of the application at the same time.
What is the fork function?
Copy a copy of the source code from a software package and develop independently on it to create different software. The term means not only a branch of version control, but also a division of the developer community, which is a form of division.
Free and open source software can be reproduced from the original development team without prior permission, which does not violate any copyright law. Reproduction of licensed proprietary software (such as Unix) also occurs from time to time.
The fork system call is used to create a new process called a child process, which runs at the same time as the process (called the system call fork), which is called the parent process. After the new child process is created, the two processes execute the next instruction after the fork () system call. The child process uses the same pc (program counter), the same CPU register, and the same open file used in the parent process.
It takes no parameters and returns an integer value. Here are the different values returned by fork ().
Negative value: failed to create child process.
Zero: return to the newly created child process.
Positive value: returns the parent process or caller. This value contains the process ID of the newly created child process [1].
Header file
# include/*# contains * /
# include/*# contains * /
Fork function prototype
Pid_tfork (void)
(pid_t is a macro definition, which essentially means that int is defined in # include)
Return value: if the call is successful, two values will be returned. The child process returns 0, and the parent process returns the child process ID;. Otherwise, the error returns-1.
Function description editing
An existing process can call the fork function to create a new process. A new process created by fork is called a childprocess. The fork function is called once but returns twice. The only difference between the two returns is that the value 0 is returned in the child process and the child process ID is returned in the parent process.
A child process is a copy of the parent process, and it will get a copy of the parent process's data space, stack, stack, and other resources. Note that the child process holds a "copy" of the above storage space, which means that the storage space is not shared between the parent and child processes.
This is the end of the article on "what the fork function refers to". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.