Linux½ø³Ì¼äͨѶ֮ÐźÅÁ¿
Ò». ʲôÊÇÐźÅÁ¿
ÐźÅÁ¿(Semaphore)-- Ï൱һ¸öÐźŵƣ¬³ÌÐòÀïÊÇÒ»¸ö·Ç¸ºÕûÊý£¬±íʾ״̬.
¿ÉÒÔÓÃÀ´±£»¤Á½¸ö»ò¶à¸ö¹Ø¼ü´úÂë¶Î£¬ÕâЩ¹Ø¼ü´úÂë¶Î²»Äܲ¢·¢µ÷Óá£ÔÚ½øÈëÒ»¸ö¹Ø¼ü´úÂë¶Î֮ǰ£¬Ï̱߳ØÐë»ñÈ¡Ò»¸öÐźÅÁ¿¡£
Èç¹û¹Ø¼ü´úÂë¶ÎÖÐûÓÐÈκÎỊ̈߳¬ÄÇôÏ̻߳áÁ¢¼´½øÈë¸Ã¿òͼÖеÄÄǸö²¿·Ö¡£Ò»µ©¸Ã¹Ø¼ü´úÂë¶ÎÍê³ÉÁË£¬ÄÇô¸ÃÏ̱߳ØÐëÊÍ·ÅÐźÅÁ¿¡£
ÆäËüÏë½øÈë¸Ã¹Ø¼ü´úÂë¶ÎµÄÏ̱߳ØÐëµÈ´ýÖ±µ½µÚÒ»¸öÏß³ÌÊÍ·ÅÐźÅÁ¿¡£ÎªÁËÍê³ÉÕâ¸ö¹ý³Ì£¬ÐèÒª´´½¨Ò»¸öÐźÅÁ¿£¬
È»ºó½«Acquire Semaphore ÒÔ¼°Release Semaphore ·Ö±ð·ÅÖÃÔÚÿ¸ö¹Ø¼ü´úÂë¶ÎµÄÊ×Ä©¶Ë¡£È·ÈÏÕâЩÐźÅÁ¿ÒýÓõÄÊdzõʼ´´½¨µÄÐźÅÁ¿¡£
ÐźÅÁ¿£ºÒ»¸öÕûÊý£»
´óÓÚ»òµÈÓÚ0ʱ´ú±í¿É¹©²¢·¢½ø³ÌʹÓõÄ×ÊԴʵÌåÊý£»
СÓÚ0ʱ´ú±íÕýÔڵȴýʹÓÃÁÙ½çÇøµÄ½ø³ÌÊý£»
ÓÃÓÚ»¥³âµÄÐźÅÁ¿³õʼֵӦ´óÓÚ0£»
Ö»ÄÜͨ¹ýP¡¢VÔÓï²Ù×÷¶ø¸Ä±ä£»
ÐźÅÁ¿ÔªËØ×é³É£º
1¡¢±íʾÐźÅÁ¿ÔªËصÄÖµ£»
2¡¢×îºó²Ù×÷ÐźÅÁ¿ÔªËصĽø³ÌID
3¡¢µÈ´ýÐźÅÁ¿ÔªËØÖµ+1µÄ½ø³ÌÊý£»
4¡¢µÈ´ýÐźÅÁ¿ÔªËØֵΪ0µÄ½ø³ÌÊý£»
¶þ¡¢Ö÷Òªº¯Êý
1.1 ´´½¨ÐźÅÁ¿
int semget(
key_t key, //±êʶÐźÅÁ¿µÄ¹Ø¼ü×Ö£¬ÓÐÈýÖÖ·½·¨£º1¡¢Ê¹ÓÃIPC——PRIVATEÈÃϵͳ²úÉú£¬ 2¡¢ÌôÑ¡Ò»¸öËæ»úÊý£¬3¡¢Ê¹ÓÃftok´ÓÎļþ·¾¶ÃûÖвúÉú
int nSemes, //ÐźÅÁ¿¼¯ÖÐÔªËظöÊý
int flag //IPC_CREAT£»IPC_EXCL Ö»ÓÐÔÚÐźÅÁ¿¼¯²»´æÔÚʱ´´½¨
)
³É¹¦£º·µ»ØÐźÅÁ¿¾ä±ú
ʧ°Ü£º·µ»Ø-1
1.2 ʹÓÃftokº¯Êý¸ù¾ÝÎļþ·¾¶Ãû²úÉúÒ»¸ö¹Ø¼ü×Ö
key_t ftok(const char *pathname,int proj_id);
·¾¶Ãû³Æ±ØÐëÓÐÏàӦȨÏÞ
1.3 ¿ØÖÆÐźÅÁ¿
int semctl(
int semid, //ÐźÅÁ¿¼¯µÄ¾ä±ú
int semnum, //ÐźÅÁ¿¼¯µÄÔªËØÊý
int cmd, //ÃüÁî
/*union senum arg */... //
)
³É¹¦£º·µ»ØÏàÓ¦µÄÖµ
ʧ°Ü£º·µ»Ø-1
ÃüÁîÏêϸ˵Ã÷:
cmd: IPC_RMID ɾ³ýÒ»¸öÐźÅÁ¿
IPC_EXCL Ö»ÓÐÔÚÐźÅÁ¿¼¯²»´æÔÚʱ´´½¨
IPC_SET ÉèÖÃÐźÅÁ¿µÄÐí¿ÉȨ
SETVAL ÉèÖÃÖ¸¶¨ÐźÅÁ¿µÄÔªËصÄֵΪ agc.val
GETVAL »ñµÃÒ»¸öÖ¸¶¨ÐźÅÁ¿µÄÖµ
GETPID »ñµÃ×îºó²Ù×Ý´ËÔªËصÄ×îºó½ø³ÌID
GETNCNT »ñµÃµÈ´ýÔªËرäΪ1µÄ½ø³ÌÊý
GETZCNT »ñµÃµÈ´ýÔªËرäΪ0µÄ½ø³ÌÊý
union senum ¶¨ÒåÈçÏ£º
union senum{
int val;
struct semid_ds *buf;
unsigned short * array;
}agc;
ÆäÖÐ semid_ds ¶¨ÒåÈçÏ£º
struct semid_ds{
struct ipc_pem sem_pem; /
Ïà¹ØÎĵµ£º
ÔÚLinuxÖУ¬Èç¹ûÒªÈýø³ÌÔÚºǫ́ÔËÐУ¬Ò»°ãÇé¿öÏ£¬ÎÒÃÇÔÚÃüÁîºóÃæ¼ÓÉÏ&¼´¿É£¬Êµ¼ÊÉÏ£¬ÕâÑùÊǽ«ÃüÁî·ÅÈëµ½Ò»¸ö×÷Òµ¶ÓÁÐÖÐÁË£º
$ ./test.sh &
[1] 17208
$ jobs -l
[1]+ 17208 Running ./test.sh &
¶ÔÓÚÒѾÔÚǰִ̨ÐеÄÃüÁҲ¿ÉÒÔÖØзŵ½ºǫִ́ÐУ¬Ê×ÏÈ°´ctrl+zÔÝÍ£ÒѾÔËÐеĽø³Ì£¬È ......
ÔÚµ±Ç°Ä¿Â¼ÏÂËÑË÷Ö¸¶¨Îļþ£º
find . -name test.txt
ÔÚµ±Ç°Ä¿Â¼ÏÂÄ£ºýËÑË÷Îļþ£º
find . -name '*.txt'
ÔÚµ±Ç°Ä¿Â¼ÏÂËÑË÷Ìض¨ÊôÐÔµÄÎļþ£º
find . -amin -10 # ²éÕÒÔÚϵͳÖÐ×îºó10·ÖÖÓ·ÃÎʵÄÎļþ
find . -atime -2 # ²éÕÒÔÚϵͳÖÐ×îºó48Сʱ·ÃÎʵÄÎļþ
find . -empty # ²éÕÒÔÚϵͳÖÐΪ¿ÕµÄÎļþ»òÕßÎļþ¼Ð
find . -g ......
Ŀ¼
1 ÒýÑÔ... 3
1.1 ±³¾°... 3
1.2 ±àдĿµÄ... 3
1.3 ¶¨Òå... 3
1.4 ²Î¿¼×ÊÁÏ... 3
2. ApacheÓëJBoss·þÎñÆ÷¼ò½é... 3
2.1 Apache·þÎñÆ÷... 3
2.2 JBoss·þÎñÆ÷... 3
3. ApacheÓëJBoss·þÎñÆ÷ÅäÖÃÕûºÏ... 3
3.1 ÈÃApacheÓëJBossÒ»Æð¹¤×÷... 3
3.1.1 ¼ò½é... 3
3.1.2 »·¾³... 3
3.1.3 °²×°... 4
3.1.4 ÅäÖÃ... ......
¹ØÓÚqt embedded phonon °²×°ÎÊÌâ¡£
¿ÉÄÜÔÚ°²×°$sudo ./configure -phonon -phonon-backend .....µÄʱºò»á˵ÕÒ²»µ½phonon ,
ºÜÃ÷ÏÔÒòΪûÓÐÕâ¸öphononÕâ¸ö¿â£¬µ±È»¾Í»áÕÒ²»µ½£¬ÔÚ±àÒëµÄʱºò£¬
ÌرðÊÇ./configure -phonon -phonon-backendµ±±àÒëºÜ¶Îʱ¼äºó»á˵£ºPhonon support cannot ...Õâ¸öʱºò¾Í¾ÍÇëÄã¼ÓÉÏ'-v'£»$sud ......