LINUX 线程函数大全
LINUX 线程函数大全
线程
创建一个缺省的线程
缺省的线程的属性:
l 非绑定
l 未分离
l 一个缺省大小的堆栈
l 具有和父线程一样的优先级
用 phread_attr_init() 创建一个缺省的属性对象,
用属性对象创建一个线程 pthread_create(3T)
int p thread_create ( pthread_t *tid, const pthread_attr_t *tattr, void *(*start_routine)(void*), void *arg );
#include<pthread.h>
pthread_attr_t tattr;
pthread_t tid;
extern void *start_routine(void *arg);
void *arg;
int ret;
/*default behavior*/
ret = pthread_create( &tid, NULL, start_routine, arg );
/*init with default attributes*/
ret = pthread_attr_init( &tattr );
/*default behavior specified*/
ret = pthread_create( &tid, &tattr, start_routine, arg );
tattr 中含有初始化线程所需的属性,值赋为 NULL 即缺省。 start_routine 是线程入口函数的起始地址。当 start_routine 返回时,相应的线程就结束了。线程结束时的退出状态值是 start_routine 函数用 phread_exit() 函数返回的返回值。当 pthread_create() 函数调用成功时,线程标识符保存在参数 tid 指针指向中。
返回值, pthread_create() 成功后返回 0 ,
EAGAIN 超过了某个限制,如 LWPs 过多。
EINVAL tattr 值非法。
创建子线程时,传给子线程的输入参数最好是 malloc() 返回的指针(这样的指针指向进程堆中的存储空间)或指向全局变量的指针,而不要是指向局部变量的指针。因为当子线程访问输入参数时,创建子线程的函数可能已结束,局部变量也就不存在了。
等待线程结束
pthread_join(3T)
int pthread_join( pthread_t tid, void **status );
#include<pthread.h>
pthread_t tid;
int ret;
int status;
&nbs
相关文档:
原贴:http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html
Published Mon, 2008/03/24 - 13:49, Updated Wed, 2009/07/15 - 23:40
Complex PHP applications, such as Drupal, can gain a lot of performance benefits from running a PHP op-code cache/accelerators
.
APC,
Alternate ......
1、下载MySQL的安装文件
安装MySQL需要下面两个文件:
MySQL-server-5.0.46.i386.rpm
MySQL-client-5.0.46.i386.rpm
2、安装MySQL
rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是
ivh
,其中i表示将安装指定的rmp软件包,V表 ......
/*
file:string.h
#ifndef _LINUX_STRING_H_
#define _LINUX_STRING_H_
/* We don't want strings.h stuff being user by user stuff by accident */
#ifdef __KERNEL__
#include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */
#include <linux/compiler.h&g ......
这篇文章介绍在LINUX下进行C语言编程所需要的基础知识.在这篇文章当中,我们将会学到以下内容:
源程序编译
Makefile的编写
程序库的链接
程序的调试
头文件和系统求助
1.源程序的编译
在Linux下面,如果要编译一个C语言源程序,我们要使用GNU的gcc编译器. &nb ......