Problems related to the shared memory of php and C ++ in linux
Source: Internet
Author: User
The shared memory of php and C ++ in linux is like a question. I want to run a multi-threaded C ++ program with tens of thousands of threads running at the same time. can I open up a shared memory, so that every thread can write to this region, and another php process can access the content in this region? Thank you !, Check out the problem of memory sharing on linux at http://www.php.net/manual/en/book.sem.php and http:/ php and C ++.
For example, if I want to run a multi-threaded C ++ program, there will be tens of thousands of threads running at the same time. can I open up a shared memory so that every thread can write to this region, another php process can access the content in this area?
Thank you!
------ Solution --------------------
Check
Http://www.php.net/manual/en/book.sem.php
And
Http://www.php.net/manual/en/book.shmop.php
Enable
------ Solution --------------------
Similar to C, shmget is a system v series API.
As you can see, Php does not share mutex. it can only be simulated using the binary semaphore of semget. pay attention to the php code logic.
C ++ first creates shm and then initializes some content. The sem is created most. php opens sem with read-only. if the failure occurs, it indicates that C ++ has not yet completed the shared memory initialization.
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