Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

[ת]VMWAREϵ÷ÕûlinuxµÄ·Ö±æÂÊ

VMWAREϰ²×°ÍêÁËlinux.defaultµÄ·Ö±æÂÊÊÇ:800x600
Òªµ÷ÕûΪ1024x768 ;ÏñËØÎªÉϰÙÍòÏñËØµÄ¹ý³ÌÈçÏÂ:
1,VMÏÂÓÐInstall vmare toolsÏÈÆô¶¯vmwareÔÚ/mnt/cdromÏÂÓÐÒ»¸ö½Ð:vmware-linux-tools.tar.gzµÄÈí¼þ°ü
2.°ÑÕâ¸öÈí¼þ°ücopyµ½/rootÏÂ,½Ó׎âѹÕâ¸ö°ü ÔÚµ±Ç°µÄĿ¼,»á²úÉúÒ»¸övmware-tools-distribµÄĿ¼
#cp vmware-li ......

Ubuntu£¨Linux£©Ê¹ÓÃEclipse´î½¨C/C++±àÒë»·¾³

ÕâÁ½Ì죬¸ø×Ô¼ºµçÄÔŪÁË˫ϵͳ£¬³ýÁËÔ­À´µÄWindows 7ϵͳÍ⣬װÉÏÁËLinuxϵͳ£¬Ê¹Óõİ汾ÊÇUbuntu
£¨µã
»÷¿Éµ½ÏàÓ¦µÄÏÂÔØÒ³Ãæ£©¡£¿ªÊ¼ÎÒ×°µÄLinux°æ±¾ÊÇfedora9£¬¶ÔÓÚÒ»¸ö¸ù±¾Ã»½Ó´¥¹ýLinuxϵͳµÄÈ˶øÑÔ£¬Ê¹ÓÃfedora£¬¼òÖ±ÈÃÈ˱ÀÀ£¡£¸ü
±ÀÀ£µÄÊÇ£¬ÎÒÓõÄÓ¢Îİ档ûµÄ°ì·¨£¬ÓÖÖØÐÂÏÂÔØLinux£¬¿Ìµú¡£×°ÏµÍ³¡£×°ÏµÍ³µÄʱºò ......

ѧϰ linux kernelµÄ½¨Òé

ÊÇÒªÓм¸¸ö½×¶ÎµÄ¡£ ¿ªÊ¼¿´ulk,
ulk×îºÃµÄµØ·½¾ÍÊÇËûËù³«µ¼µÄѧϰ·½·¨ÌرðºÃ¡£µ±ÄãÏëѧϰij·½ÃæÊ±£¬ÏÈ¿´Í·Îļþ£¬ÔÚû°Ñÿ¸öÊý¾Ý½á¹¹ÖеÄÿ¸öÊý¾ÝÔªËØÅªÇå³þ֮ǰ²»Òª¿´ÊµÏÖ´úÂë¡£
¶ÁÍêÍ·Îļþ£¬Òâζ×ÅÆäÖеÄ×éÖ¯¹ØÏµ¸ú±ðµÄµØ·½µÄÁªÏµ¾ÍÇå³þÁË£¬ÕâʱºòÄãÈ¥¿´ÊµÏֵĴúÂëÄã»á·¢ÏÖËûÒѾ­×öµÄÕýÊÇÄãËùÏëµÄ¡£
¸ú×Åulk°ÑÕâЩ»ù±¾µ ......

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

http://blog.csdn.net/dinitial/archive/2009/02/22/3923559.aspx
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 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ