Linux多线程编程的基本的函数
函数原型:
#include <pthread.h>
int pthread_create(pthread_t *restrict tidp,const pthread_attr_t *restrict attr, void *(*start_rtn)(void),void *restrict arg);
返回值:若是成功建立线程返回0,否则返回错误的编号
形式参数:
pthread_t *restrict tidp 要创建的线程的线程id指针
const pthread_attr_t *restrict attr 创建线程时的线程属性
void* (start_rtn)(void) 返回值是void类型的指针函数
vodi *restrict arg start_rtn的行参
例题1:
功能:测试建立一个新的线程
程序名称: pthread_test.c
#include <pthread.h>
#include <stdio.h>
void *create(void *arg)
...{
printf("new thread created ..... ");
}
int main(int argc,char *argv[])
...{
pthread_t tidp;
int error;
error=pthread_create(&tidp,NULL,create,NULL);
if(error!=0)
......{
printf("pthread_create is not created ... ");
return -1;
}
printf("prthread_create is created... ");
return 0;
}
编译方法:
#gcc -Wal
相关文档:
3、PHP安装
1)还是下载源码包,如:php-5.1.1.tar.gz,下载地址:http://www.php.net
2)解压缩,>tar -zxvf php-5.1.1.tar.gz
3)进入php-5.1.1,>cd php-5.1.1
4)安装配置,>./configure --prefix=/opt/php
--with-apxs2=/opt/apache/bin/apxs --with-mysql=/opt/mysql
--with-mysqli=/opt/mysql/bin/ ......
MEMCACHED安装
一、服务端。先安装libevent,再安装memcached。(注:libevent是一套跨平台的事件处理接口的封装,能够兼容包括:Windows/Linux/BSD/Solaris等操作系统的事件处理)
1、下载最新版本的libevent和memcached,笔者的安装目录为/soft
>cd /soft
>wget http://www.dange.com/memcached/dist/memcach ......
RPM有5种基本操作模式(不包括软件包建构):安装、删除、升级、查询和校验。
RPM包的名称格式,eg:caleng-1.0-1.i386.rpm。该文件名包括软件包名称“caleng”;软件版本号“1.0“,其中包括主版本号和次版本号;"i386"是软件所运行的硬件平台。
1、安装RPM包,eg: $>rpm -ivh test.rp ......
在我们在写程序的过程中,有些时候需要知道一些电脑的硬件信息,比如我们写一些需要注册的程序的时候,就需要得到某个电脑特定的信息,一般来说,网卡的物理地址是不会重复的,我们正好可以用它来做为我们识别一台电脑的标志.那如何得到网卡的物理地址呢?我们可以借助于ProcessBuilder这个类,这个类是JDK1.5新加的,以前也可以用Ru ......
原文地址:http://www.wangzhongyuan.com/archives/488.html
以下是一个Linux/Unix下由两个管道提供双向数据流的C程序,这是操作系统课程中经常使用的基本程序
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <string.h>
int m ......