易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

嵌入式arm linux蓝牙文件传输移植

嵌入式arm linux蓝牙文件传输移植
目前,蓝牙技术已经比较成熟,特别是基于手机和PC得蓝牙文件传输。
本文主要讲述基于嵌入式arm linux的蓝牙文件传输。
 
   现行2.6.x的linux内核都已经集成了bluez蓝牙驱动,对于2.4版本内核的需要到bluez官方网站下载并安装bluez蓝牙驱动。
http://www.bluez.org/d ......

Linux LVM 的使用详解

Linux LVM 的使用详解
摘要: Linux用户安装Linux操作系统时遇到的一个最常见的难以决定的问题就是如何正确地给评估各分区大小,以分配合适的硬盘空间。而遇到出现某个分区空间耗尽时,解决的方法通常是使用符号链接,或者使用调整分区大小的工具(比如Patition Magic等),但这都只是暂时解决办法,没有根本解决问题。随着L ......

读后感2 linux学习

果然是过了好久,这次又准备开始学习linux了。系统的学习和在网上找点只言片语的了解果然是不一样的。看完这点章节,自己就再做做总结吧。
我大概了解下来是这样的。对于linux的文件系统来说,下面有很多“文件”,这些“文件”包括了设备、磁盘驱动器等等。比如"\"表示根目录,而\user是用来装整个操 ......

建立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号