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

linuxÄÚºË lock free


//
ͬ²½ÎÊÌ⣺
¶Ô¹²ÏíÊý¾ÝµÄ·ÃÎÊ£¬ÐèҪͬ²½£¬»¥³â¡£
ÔÚÖжϣ¬ÇÀÕ¼£¬¶àCPU£¬¶àÏß³Ì »·¾³ÏÂÓÈÆäÖØÒª¡£
ͬ²½·ÖΪ: ×èÈûͬ²½£¬·Ç×èÈûͬ²½
×èÈûͬ²½ÓÐÐí¶àʵÏÖ·½Ê½ÁË£ºmutex, semaphore. ×èÈûͬ²½Ê¹Óò»µ±¾Í¿ÉÄÜÔì³ÉËÀËø£¬»îËø£¬ÓÅÏȼ¶·´×ª¡£
·Ç×èÈûͬ²½£º£¨ÏÖÔÚÁ÷ÐÐÈýÖÖ£©
wait free ºÜÄÑʵÏÖ£¬Ë¼ÏëÊDZ¾Ïß³ÌÓÐÏÞ²½¾ÍÍê³É£¬ÍêÈ«²»ÓÃÀíÆäÓàÏ̡߳£
lock free È·±£¶à¸öÏß³ÌÖУ¬×ÜÓÐÒ»¸öÏß³ÌÊÇÔËÐÐ×ŵġ£ÔÚÈ«¾ÖÉÏ¿´¾ÍÊÇÕâ¸öÄ£¿éÒ»Ö±ÔËÐÐÖС£
obstruction free Ï̳߳ÖÐøÔËÐУ¬µ±·¢ÏÖ¹²ÏíÊý¾Ý±»¸Ä£¬»Ø¹ö¡£
²»Äѵóö Obstruction-free ÊÇ Non-blocking synchronization ÖÐÐÔÄÜ×î²îµÄ£¬¶ø Wait-free ÐÔÄÜÊÇ×îºÃµÄ£¬µ«ÊµÏÖÄѶÈÒ²ÊÇ×î´óµÄ£¬Òò´Ë Lock-free Ëã·¨¿ªÊ¼±»ÖØÊÓ£¬²¢¹ã·ºÔËÓÃÓÚµ±½ñÕýÔÚÔËÐеijÌÐòÖУ¬±ÈÈç linux Äںˡ£
linuxÄÚºËÖоÍÖ÷ÒªÊÇʵÏÖÁËlock free
Ò»°ã²ÉÓÃÔ­×Ó¼¶µÄ read-modify-write Ô­ÓïÀ´ÊµÏÖ Lock-Free Ëã·¨£¬¸ù¾Ý´ËÀíÂÛ£¬Òµ½çÔÚÔ­×Ó²Ù×÷µÄ»ù´¡ÉÏÌá³öÁËÖøÃûµÄ CAS£¨Compare - And - Swap£©²Ù×÷À´ÊµÏÖ Lock-Free Ëã·¨£¬Intel ʵÏÖÁËÒ»ÌõÀàËƸòÙ×÷µÄÖ¸Ácmpxchg8¡£
//Ô­Óï
CAS Ô­Ó︺Ôð½«Ä³´¦ÄÚ´æµØÖ·µÄÖµ£¨1 ¸ö×Ö½Ú£©ÓëÒ»¸öÆÚÍûÖµ½øÐбȽϣ¬Èç¹ûÏàµÈ£¬Ôò½«¸ÃÄÚ´æµØÖ·´¦µÄÖµÌ滻ΪÐÂÖµ£¬CAS ²Ù×÷αÂëÃèÊöÈçÏ£º
Çåµ¥ 1. CAS αÂë

 Bool CAS(T* addr, T expected, T newValue) 
 { 
      if( *addr == expected ) 
     { 
          *addr =  newValue; 
           return true; 
     } 
     else 
           return false; 
 } 
ÔÚʵ¼Ê¿ª·¢¹ý³ÌÖУ¬ÀûÓà CAS ½øÐÐͬ²½£¬´úÂëÈçÏÂËùʾ£º
Çåµ¥ 2. CAS ʵ¼Ê²Ù×÷

 do{ 
        ±¸·Ý¾ÉÊý¾Ý£»
        »ùÓÚ¾ÉÊý¾Ý¹¹ÔìÐÂÊý¾Ý£»
 }while(!CAS( ÄÚ´æµØÖ·£¬±¸·ÝµÄ¾ÉÊý¾Ý£¬ÐÂÊý¾Ý )) 
¾ÍÊÇÖ¸µ±Á½Õß½øÐбȽÏʱ£¬Èç¹ûÏàµÈ£¬ÔòÖ¤Ã÷¹²ÏíÊý¾ÝûÓб»Ð޸ģ¬Ìæ»»³ÉÐÂÖµ£¬È»ºó¼ÌÐøÍùÏÂÔËÐУ»Èç¹û²»ÏàµÈ£¬ËµÃ÷¹²ÏíÊý¾ÝÒѾ­±»Ð޸ģ¬·ÅÆúÒѾ­Ëù×öµÄ²Ù×÷£¬È»ºóÖØÐÂÖ´ÐиղŵIJÙ×÷¡£ÈÝÒ׿´³ö CAS ²Ù×÷ÊÇ»ùÓÚ¹²ÏíÊý¾Ý²»»á±»Ð޸ĵļÙÉ裬²ÉÓÃÁ


Ïà¹ØÎĵµ£º

linux ext2 Îļþϵͳ»Ö¸´±»É¾³ýµÄÎļþ

linux   ext2   Îļþϵͳ»Ö¸´±»É¾³ýµÄÎļþ   
    
  ·¢²¼ÈÕÆÚ£º2002-08-08   
  ÎÄÕÂÄÚÈÝ£º   
  ------------------------------------------------------------------------   
  --------   
  by   ......

LinuxÏÂCÓïÑÔ±à³Ì ÐźŴ¦Àíº¯Êý

Ç°ÑÔ:ÕâÒ»ÕÂÎÒÃÇÌÖÂÛÒ»ÏÂLinuxϵÄÐźŴ¦Àíº¯Êý. 
     LinuxϵÄÐźŴ¦Àíº¯Êý: 
1.ÐźŵIJúÉú 
2.ÐźŵĴ¦Àí 
3.ÆäËüÐźź¯Êý 
--------------------------------------------------------------------------------
Ò»¸öʵÀý 
1¡£ÐźŵIJúÉú  ......

Linux¸÷·¢Ðа汾 ÓÅȱµã ¼ò½é


 
Linux¸÷·¢Ðа汾 ÓÅȱµã ¼ò½é
À´Ô´: ChinaUnix²©¿Í ¡¡ÈÕÆÚ£º 2008.01.21 13:43¡¡(¹²ÓÐ25ÌõÆÀÂÛ) ÎÒÒªÆÀÂÛ
 
Linux×îÔçÓÉLinus Benedict TorvaldsÔÚ1991Ä꿪ʼ±àд¡£ÔÚÕâ֮ǰ£¬Richard
Stallman´´½¨ÁËFree Software
Foundation£¨FSF£©×éÖ¯ÒÔ¼°GNUÏîÄ¿£¬²¢²»¶ÏµÄ±àд´´½¨GNU³ÌÐò£¨´ËÀà³ÌÐòµÄÐí¿É·½Ê½¾ùΪ ......

linuxÃüÁîµÄÈ«³Æ~~~·

תÔØ×Ô£ºhttp://www.91linux.com/html/article/go/20090205/15634.html
bin = BINaries £¨binary)
/dev = devices
/etc = ETCetera
etcetera¸½¼ÓµÄÈË, ¸½¼ÓÎï, ÒÔ¼°ÆäËü, µÈµÈ
/lib = LIBrary
/proc = PROCesses
/sbin
= Superuser BINaries
/tmp = TeMPorary
/usr = Unix Shared
Resources
/var = ......

Linuxϳ£ÓÃCÓïÑÔ×Ö·û´®²Ù×÷º¯Êý

stroul£¬
strdup
snprintf()
atio
 
CÖг£ÓÃ×Ö·û´®²Ù×÷º¯Êý
#include <string.h>
 
size_t strlen(const char *s)   ²âÁ¿×Ö·û´®³¤¶ÈsµÄʵ¼Ê³¤¶È¡£
ÀýÈçs[20]="abc",ÄÇôstrlen(s)µÄ½á¹ûÊÇ3£¬¶ø²»ÊÇ20.Õâ¾ÍÊÇʵ¼Ê³¤¶È
 
char *strcat(const char *s1, const *s2)  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ