Complex PC problems under Linux-multi-process programming/semaphore communication/shared storage area

Source: Internet
Author: User
Tags semaphore

Process-related functions

pid_t Fork ();

header file :unistd.h,sys/types.h

role : Establish a new process (child process) that shares the code snippet with the original process (the parent process) and has a copy of the parent process's other resources (data, stacks, and so on). (Because all States of the parent process are inherited, the child process runs down from the Fork ). (Note: The child process inherits all the data from the parent process, but when executed, the data is separate and no longer affects each other.) The fork function copies the data segments and stacks, just "logically" on, not "physical", that is, the physical space on the two process data and stack segments are still shared, when there is a process to write a certain data, then the data between two processes is different, The system separates the "pages" of the difference from the physical. The overhead of the system can be minimized. )

parameters : None

return value : Thepid_t type, which is an alias of Int. If called successfully, returns two values. The fork () function returns the process ID of the child process in the parent process and returns 0 in the child process . This feature can be used to enable a process to identify itself as a parent or child process. If an error occurs, a negative value is returned.

Semaphore correlation function

Complex PC problems under Linux-multi-process programming/semaphore communication/shared storage area

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.