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


相关文档:

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—select详解

linux—select详解
select系统调用时用来让我们的程序监视多个文件句柄的状态变化的。程序会停在select这里等待,直到被监视的文件句柄有一个或多个发生了状态改变。
关于文件句柄,其实就是一个整数,通过socket函数的声明就明白了:
int socket(int domain, int type, int protocol);
我们最熟悉的句柄是0、1、2 ......

安装u盘linux系统~~

可安装在U盘上的操作系统 Puppy Linux 4.1 Beta
一、 U盘安装Puppy Linux方法
1、下载安装FlashBoot。可以在google上搜一下下载
运行FlashBoot,按下图红色框选择,点【下一步】
选择你下载的iso镜像,【下一步】
选择你的U盘盘符,不要选错了。点【下一步】
这一步要注意,默认选择的是不格盘。 ......

Freebsd与linux对比分析


FreeBSD是一个完整的操作系统,包含了从开发工具到各种各样的应用程序。
目前人们认为FreeBSD在稳定性和网络运作上的性能要优于Linux。
它由一个软件开发的核心团队来维护,整个原始程序代码会有组织地进行更新,所以程序代码比较有一致性。
由于人们对FreeBSD的认识比较少,使用范围也比较小,导致了它在对一些新产品 ......

读后感2 linux学习

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