Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ƽ̨ÏÂserverÔËάÎÊÌâ·ÖÎöÓ붨λ

    ½áºÏÎÒ¹¤×÷ÖÐÅöµ½µÄÔËάÎÊÌ⣬×ܽáÒ»ÏÂlinuxÏÂserver³£¼ûµÄÔËάÎÊÌâÒÔ¼°¶¨Î»·½Ê½¡£ÕâÀïµÄserverÖ÷ÒªÖ¸×ÔÖ÷¿ª·¢µÄÂß¼­server£¬web srvÒòΪͨ³£²ÉÓÃͨÓõļܹ¹ËùÒÔÎÊÌâ±È½ÏÉÙ¡£
    Âß¼­serverͨ³£µÄ´¦ÀíÄÜÁ¦ÔÚ3k/s - 1w/sÖ®¼ä£¬ÒòÒµÎñÌØµã¶ø²»Í¬¡£Âß¼­serverÒ»°ãÊÇ×ÔÖ÷¿ª·¢µÄ£¬ËäÈ»ÔÚÉÏÏ ......

linux¾ÈԮģʽ

ÐÞ¸Ä/etc/fstab, /etc/rc.d/rc.sysinitµÈϵͳÆô¶¯ÎļþʱÎó²Ù×÷¾Í»áÔì³ÉlinuxÎÞ·¨½øÈ룬ÓÐrescueÅÌ¿ÉÒÔÈÝÒ×ÐÞ¸´£¬Õâ¸ö·½·¨ÊʺÏÓÚûÓÐrescueÅÌʱÐÞ¸´ÏµÍ³¡£
grub²Ëµ¥ÖÐÑ¡Ôñlinux,°´e,e,½øÈë±à¼­Ä£Ê½£¬kernel (hd0,0)/vmlinuz root=/dev/hda2.....ÕâÒ»ÐÐ×îºó¼ÓÉÏinit=/bin/bash,Ð޸ĺúó°´enter,bÒýµ¼Ð޸ĺóµÄÒýµ¼ÐÅÏ¢ÀàËÆÈçÏ ......

study linux website

1. LinuxCommand
¡¡¡¡LinuxCommandÊÇÒ»¸öѧϰLinuxÃüÁîÐÐ×îºÃµÄÍøÕ¾Ö®Ò»¡£ÍøÕ¾·ÖΪ£ºÑ§Ï°Shell¡¢Ð´Shell½Å±¾¡¢½Å±¾¿â¡¢³¬¼¶MANÒ³Ãæ¡£
       http://linuxcommand.org/
2. O’ReillyµÄLinuxÃüÁîÖ¸ÄÏĿ¼
¡¡¡¡O’ReillyµÄLinuxÃüÁîÖ¸ÄÏĿ¼ÊÇÒ»¸ö¼«ºÃµÄ¿ìËٲο¼Ö¸ÄÏ£¬ÁгöÁË´ó ......

¶Áºó¸Ð2 linuxѧϰ

¹ûÈ»ÊǹýÁ˺þã¬Õâ´ÎÓÖ×¼±¸¿ªÊ¼Ñ§Ï°linuxÁË¡£ÏµÍ³µÄѧϰºÍÔÚÍøÉÏÕÒµãÖ»ÑÔÆ¬ÓïµÄÁ˽â¹ûÈ»ÊDz»Ò»ÑùµÄ¡£¿´ÍêÕâµãÕ½ڣ¬×Ô¼º¾ÍÔÙ×ö×ö×ܽá°É¡£
ÎÒ´ó¸ÅÁ˽âÏÂÀ´ÊÇÕâÑùµÄ¡£¶ÔÓÚlinuxµÄÎļþϵͳÀ´Ëµ£¬ÏÂÃæÓкܶà“Îļþ”£¬ÕâЩ“Îļþ”°üÀ¨ÁËÉ豸¡¢´ÅÅÌÇý¶¯Æ÷µÈµÈ¡£±ÈÈç"\"±íʾ¸ùĿ¼£¬¶ø\userÊÇÓÃÀ´×°Õû¸ö²Ù ......

½¨Á¢ARM+LinuxÓ¦ÓóÌÐòµ÷ÊÔ»·¾³

 
½¨Á¢ARM+LinuxÓ¦ÓóÌÐòµ÷ÊÔ»·¾³
 
Gdb+gdbserver+insight»·¾³µÄ´î½¨
1.    ÏÂÔØgdbÔ´´úÂë    http://ftp.gnu.org/gnu/gdb/
 
2.    ÅäÖð²×°gdb+gdbser
$ tar jxvf gdb-6.6.tar.bz2
$ cd x/gdb
$ ./configure --target=arm-linux --prefix=/usr/lo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ