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
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
4、mcrypt安装
1)安装mcrypt之前,必须安装libmcrypt和mhash,先去http://www.sourceforge.net
下载Libmcrypt,mhash,mcrypt安装包
2)先安装Libmcrypt
>tar -zxvf libmcrypt-2.5.8.tar.gz
>cd libmcrypt-2.5.8
>./conf ......
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 ......
原文地址: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 ......