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

linux wait£¨£©²»Ìî²ÎÊý µÈ´ý×ÓÏß³Ì

#include <semaphore.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>

void print(pid_t pid);
sem_t *sem;/*¶¨ÒåposixÓÐÃûÐźŵÆ*/
int val;/*¶¨ÒåÐźŵƵ±Ç°Öµ*/

int main(int argc,char *argv[])
{
int n=0;

if(argc!=2)
{
printf("please input a sem name!\n");
exit(1);
}

sem=sem_open(argv[1],O_CREAT,0644,2);/*´ò¿ªÒ»¸öÐźŵƣ¬³õÖµÉèΪ2*/
while(n++ <5)/*Ñ­»·´´½¨5¸ö×Ó½ø³Ì£¬Ê¹ËûÃÇͬ²½ÔËÐÐ*/
{
if(fork()==0)
{
sem_wait(sem);/*ÉêÇëÐźŵÆ*/
print(getpid());/*µ÷Óù²Ïí´úÂë¶Î*/
sleep(1);
sem_post(sem);/*ÊÍ·ÅÐźŵÆ*/
printf("I'm finished,my pid is %d\n",getpid());
exit(0);//return 0;
}
}

wait();/*µÈ´ýËùÓÐ×Ó½ø³Ì½áÊø*/-----ÕâÀïwait¿ÉÒÔ²»Ìî²ÎÊýµÈ´ýËùÓÐ×Ó½ø³ÌÂð£¿
//while(wait(NULL)!= -1)
// ;
sem_close(sem);
sem_unlink(argv[1]);
        printf("---reach here---\n");
exit(0);
}

void print(pid_t pid)
{
printf("I get it,my pid is %d\n",pid);
sem_getvalue(sem,&val);
printf("Now the semvalue is %d\n",val);
}

³ÌÐòÔËÐнá¹û£º
[ken@localhost 3]$ ./sem_in_mprocess test        &


Ïà¹ØÎÊ´ð£º

ʹÓÃStruts2ÉÏ´«Îļþ£¬ÔÚlinuxϱ¨´í

ʹÓÃStruts2ÉÏ´«Îļþ£¬ÔÚlinuxϱ¨´í
2009-09-29 14:56:20,801 [org.apache.struts2.interceptor.FileUploadInterceptor]-[ERROR] Processing of multipart/form-data request failed. c:/temp/upload__1dcd07ee_12 ......

ÇëÎÊÓÐûÓÐÈ«ÖÐÎĵÄlinuxϵͳ£¿

ÎÒÓùýubuntu8.10°æ±¾£¬´ÓverycdÏÂÔصġ£

ÏÂÔغó£¬ÊÇ°ëÓ¢ÎÄ¡£ÇÒÎÒ¶ÔlinuxϵͳµÄ²Ù×÷Àí½â²»ÉÒò´Ë×°ÖÐÎÄÊäÈë·¨¶¼¸ãÁ˺þá£

È»ºó°´ÕÕÍøÉϵĽ̸̳üÐÂÖÐÎĽçÃ棬µ«ÊǸüÐÂÁË1ÍíÉϺóÌáʾÖжϡ­¡­Àס£
......

linux ʹÓÃuÅÌ°²×°ÎÊÌâ

ÎÒÓÃuÅÌ°²×°debian£¬°´ÕÕÍøÉϵķ½·¨×öºÃuÅÌÆô¶¯Å̺󣬽«biosÉèÖÃΪUsb-fddģʽ£¨uÅÌÖ»ÄÜÔÚÕâ¸öģʽÏÂÆô¶¯£©£¬ÄÜÕý³£Æô¶¯¡£½øÈëÅäÖÃÒ³ÃæºóÔÚɨÃècd-romʱÌáʾÎÞ.iso¾µÏñ¡£Õâ¿ÉÔõô°ì£¿
ÍøÉÏÓÐÈË˵ҪÓÃgrubÒýµ¼ÎªuÅ ......

LinuxÏ°²×°ÎÊÌâ

Ô­ÏȵÄGCC°æ±¾Îª4.1.2,ÎÒÖØбàÒë°²×°ÁËGCC4.3.2£¬µ«ÊDZàÒëÍê³ÌÐòÔËÐгÌÐòʱ»á³öÏÖversion `GLIBCXX_3.4.9' not found Õâ¸öÎÊÌ⣬ÎÒ²»Ì«Ã÷°×Ôõô»ØÊ£¬Çë¸÷λ´óϺָµãһϡ£
ÊÖ¶¯ÔÙ×°Ò»´Îglibc*_3.4.9

ÕâÊÇÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ