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

Notes for Advanced Linux Programming 4. Threads

4.  Threads
To use the POSIX standard thread API (pthreads), link libpthread.so
to your program.
4.1. Thread Creation
Each thread in a process is identified by a thread ID,
pthread_t.
The pthread_self function returns the thread ID of the current
thread.
This thread IDs can be compared with the pthread_equal
function.
if (!pthread_equal (pthread_self (),
other_thread))
    pthread_join
(other_thread, NULL);
each thread executes a thread function:
void * function(void *)
The pthread_create function creates a new thread.
A pointer to a pthread_t variable: store the thread ID of
the new thread.
A pointer to a thread attribute object. You can pass NULL
to use the default attributes.
A pointer to the thread function. void* (*) (void*)
A thread argument value of type void*.
Compile and link this program:
% cc -o thread-create thread-create.c
–lpthread
A thread exits in two ways.
return from the thread function. The function return value
is the thread return value.
explicitly call pthread_exit. The argument to pthread_exit
is the thread’s return value.
Create a Thread
#include <pthread.h>
#include <stdio.h>
/* Prints x’s to stderr. The parameter is
unused. Does not return. */
void* print_xs (void* unused)
{
    while (1)
        fputc (‘x’, stderr);
    return NULL;
}
/* The main program. */
int main ()
{
    pthread_t thread_id;
    /* Create a new thread. The new thread will run the print_xs function.
*/
    pthread_create (&thread_id, NULL, &print_xs, NULL);
    /* Print o’s continuously to stderr. */
    while (1)
        fputc (‘o’, stderr);
    return 0;
}
4.1.1. Passing Data to Threads
Listing 4.2 (thread-create2) Create Two
Threads
#include <pthread.h&g


Ïà¹ØÎĵµ£º

Linux쵀ping6

×òÌì·Ö±ðÊÔÓÃÁËÒ»ÏÂLinuxϺÍWindowsϵÄIPv6 Ping£¬·¢ÏÖÎÞ·¨ping Link-localµØÖ·£¬°Ù˼²»µÃÆä½â£¬ËìÉÏÍøgoogleһϣ¬ÖÕÓÚÕÒµ½ÁËÔ­Òò¡£
Windows XPϵÄIPv6µØÖ·£º
Ethernet adapter Test:
        Connection-specific DNS Suffix  . :
      & ......

Linux EXT3Îļþϵͳϳɹ¦»Ö¸´ÎóɾµÄÎļþ

¡¡¡¡»·¾³£ºCentOS 5.3 x86_64Ï£¬/dev/sdb1ΪÊý¾Ý·ÖÇø/data0£¬EXT3Îļþϵͳ¡£
¡¡¡¡Ç°Òò£ºÎóɾÁË/data0/tcsql/cankao/phpcws-1.5.0/httpcws.cppÎļþ¡£ÓÉÓÚÍüÁ˱¸·Ýhttpcws.cppÎļþ£¬ÖØÐ¿ª·¢¹¤×÷Á¿½Ï´ó£¬Òò´ËÖ»Óлָ´¸ÃÎļþÒ»Ìõ·¿É×ß¡£
¡¡¡¡debugfsÃüÁîÕë¶ÔEXT2·ÖÇø»¹ÐУ¬µ«¶ÔEXT3·ÖÇø¾Í°ï²»ÉÏæÁË¡£Å¼È»·¢ÏÖµÄÒ»¿î¿ªÔ´Èí ......

°²×°uÅÌlinuxϵͳ~~

¿É°²×°ÔÚUÅÌÉϵIJÙ×÷ϵͳ Puppy Linux 4.1 Beta
Ò»¡¢ UÅ̰²×°Puppy Linux·½·¨
1¡¢ÏÂÔØ°²×°FlashBoot¡£¿ÉÒÔÔÚgoogleÉÏËÑÒ»ÏÂÏÂÔØ
ÔËÐÐFlashBoot£¬°´ÏÂͼºìÉ«¿òÑ¡Ôñ£¬µã¡¾ÏÂÒ»²½¡¿
Ñ¡ÔñÄãÏÂÔØµÄiso¾µÏñ£¬¡¾ÏÂÒ»²½¡¿
Ñ¡ÔñÄãµÄUÅÌÅÌ·û£¬²»ÒªÑ¡´íÁË¡£µã¡¾ÏÂÒ»²½¡¿
ÕâÒ»²½Òª×¢Ò⣬ĬÈÏÑ¡ÔñµÄÊDz»¸ñÅÌ¡£ ......

UNIX/Linux ϵͳ´ÅÅÌ ¿Õ¼ä¼à¿Ø ×Ô¶¯»¯½Å±¾ ʾÀý

UNIX/Linux ϵͳ´ÅÅÌ ¿Õ¼ä¼à¿Ø ×Ô¶¯»¯½Å±¾ ʾÀý
1. ·ÖÇø¼à¿Ø /root/disktab ÎļþʾÀý
2. checkdisk ½Å±¾³õʼ»¯²¿·Ö
3. checkdisk ½Å±¾·ÖÎö /root/disktab Îļþ²¿·Ö
4.ÖеĽű¾ÊµÏÖÁËʵʱ¼à¿Ø²¢¼ì²â·ÖÇø×´¿ö£¬Í¨¹ýÇ°Ãæ»ñµÃµÄÓû§¶¨ÒåµÄãÐÖµºÍ df ÃüÁîµÄÊä³ö½øÐбȽϣ¬Èç¹û df ÏÔʾµÄij¸ö·ÖÇøµÄ¿Õ¼äÕ¼Óó¬¹ýÁËÓû§¶¨ÒåµÄã ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ