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

linuxÏÂCÓïÑÔ¶àÏ̱߳à³ÌʵÀý


À¼´óÂÛ̳ÉϵÄÒ»¸öÌû×Ó¡«¡«
ѧ¶«Î÷£¬ÍùÍùʵÀý²ÅÊÇ×îÈÃÈ˸ÐÐËȤµÄ£¬ÀÏÊÇѧ»ù´¡ÀíÂÛ£¬²»¶¯ÊÖ£¬¸Ð¾õûÓгɾ͸У¬ºÇºÇ¡£
ÏÂÃæÏÈÀ´Ò»¸öʵÀý¡£ÎÒÃÇͨ¹ý´´½¨Á½¸öÏß³ÌÀ´ÊµÏÖ¶ÔÒ»¸öÊýµÄµÝ¼Ó¡£
»òÐíÕâ¸öʵÀýûÓÐʵ¼ÊÔËÓõļÛÖµ£¬µ«ÊÇÉÔ΢¸Ä¶¯Ò»Ï£¬ÎÒÃǾͿÉÒÔÓõ½ÆäËûµØ·½È¥À­¡£
ÏÂÃæÊÇÎÒÃǵĴúÂ룺
/*thread_example.c : c multiple thread programming in linux
*author : falcon
*E-mail : tunzhj03@st.lzu.edu.cn
*/
#include <pthread.h>
#include <stdio.h>
#include <sys/time.h>
#include <string.h>
#define MAX 10
pthread_t thread[2];
pthread_mutex_t mut;
int number=0, i;
void *thread1()
{
printf ("thread1 : I'm thread 1\n");
for (i = 0; i < MAX; i++)
{
printf("thread1 : number = %d\n",number);
pthread_mutex_lock(&mut);
number++;
pthread_mutex_unlock(&mut);
sleep(2);
}
printf("thread1 :Ö÷º¯ÊýÔÚµÈÎÒÍê³ÉÈÎÎñÂð£¿\n");
pthread_exit(NULL);
}
void *thread2()
{
printf("thread2 : I'm thread 2\n");
for (i = 0; i < MAX; i++)
{
printf("thread2 : number = %d\n",number);
pthread_mutex_lock(&mut);
number++;
pthread_mutex_unlock(&mut);
sleep(3);
}
printf("thread2 :Ö÷º¯ÊýÔÚµÈÎÒÍê³ÉÈÎÎñÂð£¿\n");
pthread_exit(NULL);
}
void thread_create(void)
{
int temp;
memset(&thread, 0, sizeof(thread)); //comment1
/*´´½¨Ïß³Ì*/
if((temp = pthread_create(&thread[0], NULL, thread1, NULL)) != 0) //comment2
printf("Ïß³Ì1´´½¨Ê§°Ü!\n");
else
printf("Ïß³Ì1±»´´½¨\n");
if((temp = pthread_create(&thread[1], NULL, thread2, NULL)) != 0) //comment3
printf("Ïß³Ì2´´½¨Ê§°Ü&q


Ïà¹ØÎĵµ£º

Linux»ù±¾ÃüÁî×¢Ïú¡¢¹Ø»ú¡¢ÖØÆô

¡¡¡¡×¢ÏúϵͳµÄlogoutÃüÁî
¡¡¡¡1£¬Logout ×¢ÏúÊǵǽµÄÏà¶Ô²Ù×÷£¬µÇ½ϵͳºó£¬ÈôÒªÀ뿪ϵͳ£¬Óû§Ö»ÒªÖ±½ÓÏ´ïlogoutÃüÁî¼´¿É:
¡¡¡¡[root@localhost root]#logout
¡¡¡¡Red Hat Linuxrelease 9(Shike)
¡¡¡¡Kernel 2.4.20.8 on an i686
¡¡¡¡Login: ← »Øµ½µÇ½µÄ»­Ãæ
¡¡¡¡2£¬¹Ø»ú»òÖØÐÂÆô¶¯µÄshutdownÃüÁî
¡¡¡¡Shu ......

Linuxϸ÷Ŀ¼µÄ×÷ÓÃ

 Ä¿Â¼½á¹¹¼°Ö÷ÒªÄÚÈÝ “/”¸ùĿ¼²¿·ÖÓÐÒÔÏÂ×ÓĿ¼£º /usr Ŀ¼°üº¬ËùÓеÄÃüÁî¡¢³ÌÐò¿â¡¢ÎĵµºÍÆäËüÎļþ¡£ÕâЩÎļþÔÚÕý³£²Ù×÷Öв»»á±»¸Ä±äµÄ¡£Õâ¸öĿ¼Ҳ°üº¬ÄãµÄLinux·¢Ðа汾µÄÖ÷ÒªµÄÓ¦ÓóÌÐò£¬Æ©È磬Netscape¡£ /var Ŀ¼°üº¬ÔÚÕý³£²Ù×÷Öб»¸Ä±äµÄÎļþ£º¼ÙÍÑ»úÎļþ¡¢¼Ç¼Îļþ¡¢¼ÓËøÎļþ¡¢ÁÙʱÎļþºÍÒ³¸ñÊ ......

¹ØÓÚLinux ÎļþϵͳÖз¾¶µÄÀí½â

×÷Õߣº±±ÄÏÄϱ±
À´×Ô£ºLinuxSir.Org
ÕªÒª£ºÔÚLinux²Ù×÷ϵͳµÄÎļþ¹ÜÀíÖУ¬ÃüÁîÐÐģʽ£¨ÔÚ¿ØÖÆ̨»òÖÕ¶ËÏ£©µÄÎļþ»òĿ¼¹ÜÀí£¬ÒªÉ漰·¾¶ÕâÒ»¸ÅÄÕâÊÇLinuxÃüÁîÐвÙ×÷µÄ×î»ù´¡µÄ»ù´¡¡£Èç¹ûÎÒÃÇÁ˽âÁË·¾¶µÄ¸ÅÄ¾Í¿ÉÒÔËæÐÄËùÓûµÄ½øÈëÈκÎĿ¼£¬½øÐÐÎÒÃÇÒª×öµÄ¹¤×÷¡£
Ŀ¼
 
4.1 ¾ø¶Ô·¾¶£»
4.2 Ïà¶Ô·¾¶£»
5 ......

Linux ÎļþºÍĿ¼¹ÜÀíÖ®Áгö¡¢É¾³ý¡¢¸´ÖÆ¡¢Òƶ¯¼°¸ÄÃû

×÷Õߣº±±ÄÏÄϱ±
À´×Ô£ºLinuxSir.Org
ÕªÒª£ºLinux ÃüÁîÐÐģʽÏÂÀ´²Ù×÷Îļþ¹ÜÀí»¹ÊDZȽÏÖØÒªµÄ£¬ËäȻĿǰÔÚLinux×ÀÃæÉÏÄÜÍê³É´ó²¿·ÝµÄÎļþ¹ÜÀí¹¤×÷£¬µ«¾ÍЧÂÊÀ´Ëµ£¬»¹ÊÇÃüÁîÐÐģʽ¸üΪǿ´ó¡£×îÖØÒªµÄÊÇÔÚÎı¾²Ù×÷½çÃæºÍͼÐνçÃæͨÓá£Èç¹ûÄúÊÇ·þÎñÆ÷¹ÜÀíÈËÔ±£¬ÄúÄÜÌå»áµ½ÃüÁîÐÐϵÄÎļþ¹ÜÀí¹¤¾ßÊǺεÈÖØÒª¡£±¾ÎÄÉæ¼°ÁËĿ¼º ......

Linux Îļþϵͳ¸ÅÊö

 ×÷Õߣº±±ÄÏÄϱ±
À´×Ô£ºLinuxSir.Org
ÕªÒª£º ±¾ÎÄͨ¹ýÎļþϵͳµÄ¶¨Òå˵Æð£¬È»ºóͨ¹ýÒýÎļòµ¥µÄ½éÉÜÁËÒ»ÏÂÎļþϵͳÀàÐÍ£»¶ÔLinux³£ÓõÄext2¡¢ext3¼°reiserfs ¸ù¾Ý±¾ÈËʹÓþ­ÑéÒ²·º·ºµÄ̸ÁË̸£¬µ«²¢²»ÊÇרҵµÄ¡£ÈçºÎÔĶÁ±¾ÎÄ£¬»¹ÊÇÓÃÂí¿Ë˼ÀíÂÛ¸æËßÎÒÃǵķ½·¨£ºÒ»·ÖΪ¶þ£¬±ß¿´±ßÅú°É£»Ä¿Â¼Ë÷Òý Ò»¡¢Ê²Ã´ÊÇÎļþϵͳ £¨F ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ