php和C++在linux下共享内存的有关问题

WBOY
Release: 2016-06-13 13:21:43
Original
782 people have browsed it

php和C++在linux上共享内存的问题
如题,我想运行一个多线程的C++程序,会有上万个线程同时运行,能否开辟一块共享内存,使得每个线程都可以向这块区域里写,而另外的一个php进程可以访问到这块区域里的内容?
谢谢!

------解决方案--------------------
看下
http://www.php.net/manual/en/book.sem.php

http://www.php.net/manual/en/book.shmop.php
都需要先enable
------解决方案--------------------
看样和C一样啊,shmget这种SYSTEM V系列的API。

看样Php没有进程共享mutex,只能用semget的二值信号量模拟了,注意php的代码逻辑。

C++先创建shm再初始化一些内容,最创建sem,php以只读打开sem,失败应该退出表明C++还没有初始化完成共享内存。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template