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


相关文档:

Ubuntu(Linux)使用Eclipse搭建C/C++编译环境

这两天,给自己电脑弄了双系统,除了原来的Windows 7系统外,装上了Linux系统,使用的版本是Ubuntu
(点
击可到相应的下载页面)。开始我装的Linux版本是fedora9,对于一个根本没接触过Linux系统的人而言,使用fedora,简直让人崩溃。更
崩溃的是,我用的英文版。没的办法,又重新下载Linux,刻碟。装系统。装系统的时候 ......

1.初级入门 xp sqlplus 连接 linux虚拟机 oracle

1.首先看看在xp下是否能够ping通虚拟机的ip(虚拟机查看ip命令:ifconfig,此命令要求有root权限,或者用 /sbin/ifconfig).
2.在第一步成功的基础上,要配置xp下oracle安装目录下的tnsnames.ora这个文件(我的路径是:D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN,这个路径因机器而异)
    首先在tnsnam ......

Linux LVM 的使用详解

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

建立ARM+Linux运行环境

http://blog.csdn.net/dinitial/archive/2009/02/22/3923447.aspx
前一个阶段主要是在Windowsxp下,通过ADS1.2、H-JTAG和DNW来对代码进行编辑和调试。现在转到Linux下,利用RedHat9.0+虚拟机作为开发环境,这里将这两天来对环境的配置及其遇到的问题总结一下。
       开发板为GEC2410,在 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号