Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ʹÓÃlinux¹²ÏíÄÚ´æµÄʵÏÖµÄphpÄÚ´æ¶ÓÁÐ

<?php
/**
* ʹÓù²ÏíÄÚ´æµÄPHPÑ­»·ÄÚ´æ¶ÓÁÐʵÏÖ
* Ö§³Ö¶à½ø³Ì, Ö§³Ö¸÷ÖÖÊý¾ÝÀàÐ͵Ĵ洢
* ×¢: Íê³ÉÈë¶Ó»ò³ö¶Ó²Ù×÷,¾¡¿ìʹÓÃunset(), ÒÔÊÍ·ÅÁÙ½çÇø
*
* @author wangbinandi@gmail.com
* @created 2009-12-23
*/
class SHMQueue
{
private $maxQSize = 0; // ¶ÓÁÐ×î´ó³¤¶È

private $front = 0; // ¶ÓÍ·Ö¸Õë
private $rear = 0; // ¶ÓβָÕë

private $blockSize = 256; // ¿éµÄ´óС(byte)
private $memSize = 25600; // ×î´ó¹²ÏíÄÚ´æ(byte)
private $shmId = 0;

private $filePtr = './shmq.ptr';

private $semId = 0;
public function __construct()
{
$shmkey = ftok(__FILE__, 't');

$this->shmId = shmop_open($shmkey, "c", 0644, $this->memSize );
$this->maxQSize = $this->memSize / $this->blockSize;

// Éê請Ò»¸öÐźÅÁ¿
$this->semId = sem_get($shmkey, 1);
sem_acquire($this->semId); // ÉêÇë½øÈëÁÙ½çÇø

$this->init();
}

private function init()
{
if ( file_exists($this->filePtr) ){
$contents = file_get_contents($this->filePtr);
$data = explode( '|', $contents );
if ( isset($data[0]) && isset($data[1])){
$this->front = (int)$data[0];
$this->rear = (int)$data[1];
}
}
}

public function getLength()
{
return (($this->rear - $this->front + $this->memSize) % ($this->memSize) )/$this->blockSize;
}

public function enQueue( $value )
{
if ( $this->ptrInc($this->rear) == $this->front ){ // ¶ÓÂú
return false;
}

$data = $this->encode($value);
shmop_write($this->shmId, $data, $this->rear );
$this->rear = $this->ptrInc($this->rear);
return true;
}

public function deQueue()
{
if ( $this->front == $this->rear ){ // ¶Ó¿Õ
return false;
}
$value = shmop_read($this->shmId, $this->front, $this->blockSize-1);
$this->front = $this->ptrInc($this->front);
return $this->decode($value);
}

private function pt


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì (Æß) SDPЭÒé

Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖЭÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀЭÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......

LinuxÏÂSVN°²×°ÅäÖÃÈ«³Ìʵ¼


Ò»¡¢°²×°SVNĬÈϰ²×°µ½/usr/local/binÏÂÃæ
¶þ¡¢´´½¨²Ö¿â svnadmin create /home/svnrepo
/root/svnrepoΪËù´´½¨²Ö¿âµÄ·¾¶£¬ÀíÂÛÉÏ¿ÉÒÔÊÇÈκÎĿ¼
Èý¡¢ÐÞ¸ÄÅäÖÃÎļþ/home/svnrepo/conf/svnserve.conf
#È¥µô#[general]Ç°ÃæµÄ#ºÅ
[general]
#ÄäÃû·ÃÎʵÄȨÏÞ£¬¿ÉÒÔÊÇread,write,none,ĬÈÏΪread
anon-access = none
......

ѧϰlinuxǶÈëʽÓйØÍøÕ¾ºÍblog(²»¶¨ÆÚ¸üУ©

http://www.linuxgraphics.cn/android/index.html
http://blog.chinaunix.net/u2/85805/
http://blog.csdn.net/stevenliyong/category/578556.aspx
http://blog.csdn.net/cuijpus/archive/2008/06/15/2549803.aspx
http://dbus.freedesktop.org/doc/dbus-tutorial.html#glib-client
http://www.ibm.com/developerworks ......

linuxÖÐÓÃshell»ñÈ¡×òÌì¡¢Ã÷Ìì»ò¶àÌìǰµÄÈÕÆÚ

linuxÖÐÓÃshell»ñÈ¡×òÌì¡¢Ã÷Ìì»ò¶àÌìǰµÄÈÕÆÚ:
ÔÚLinuxÖжÔman date -d ²ÎÊý˵µÄ±È½ÏÄ£ºý,ÒÔϾÙÀý½øÒ»²½ËµÃ÷:
# -d, --date=STRING display time described by STRING, not `now’
[root@Gman root]# date -d next-day +%Y%m%d #Ã÷ÌìÈÕÆÚ
20091024
[root@Gman root]# date -d last-day +%Y%m%d #×òÌìÈÕÆÚ
20091 ......

phpÖÐʵÏÖ¶àÏß³Ì

phpÖÐʵÏÖ¶àÏß³Ì
PHPÖÐʵÏÖ¶àÏß³Ì? ¿´µ½Õâ¸ö±êÌâ ÄãÒ»¶¨ÒÔΪÎÒ·èÁË..µ«ÊÇÊÂʵÉÏÎÒÕæµÄÕâô×öÁË.
ÏÂÃæÊÇÎÒµÄһЩ×ö·¨ ÒѾ­ÊµÑé¹ý. ȷʵ¿ÉÒÔµÄ.
ÎÒÃÇÖªµÀPHP±¾ÉíÊDz»Ö§³Ö¶àÏß³ÌµÄ µ«ÊÇÎÒÃǵÄWEB·þÎñÆ÷ÊÇÖ§³Ö¶àÏ̵߳Ä.
Ò²¾ÍÊÇ˵¿ÉÒÔͬʱÈöàÈËÒ»Æð·ÃÎÊ. ÕâÒ²ÊÇÎÒÔÚPHPÖÐʵÏÖ¶àÏ̵߳Ļù´¡.
¼ÙÉèÎÒÃÇÏÖÔÚÔËÐеÄÊÇa.phpÕâ¸öÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ