易截截图软件、单文件、免安装、纯绿色、仅160KB

Linux操作系统下的多线程编程详细解析(2)


2、线程的终止
    如果进程中任何一个线程中调用exit,_Exit,或者是_exit,那么整个进程就会终止,
    与此类似,如果信号的默认的动作是终止进程,那么,把该信号发送到线程会终止进程。
    线程的正常退出的方式:
       (1) 线程只是从启动例程中返回,返回值是线程中的退出码
       (2) 线程可以被另一个进程进行终止
       (3) 线程自己调用pthread_exit函数
    两个重要的函数原型:
#include <pthread.h>
void pthread_exit(void *rval_ptr);
/*rval_ptr 线程退出返回的指针*/
int pthread_join(pthread_t thread,void **rval_ptr);
   /*成功结束进程为0,否则为错误编码*/
    例程6
    程序目的:线程正常退出,接受线程退出的返回码
    程序名称:pthread_exit.c
/********************************************************************************************
**    Name:pthread_exit.c
**    Used to study the multithread programming in Linux OS
**    A example showing a thread to exit and with a return code.
**    Author:zeickey
**    Date:2006/9/16        
**    Copyright (c) 2006,All Rights Reserved!
*********************************************************************************************/
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
void *create(void *arg)
{
    printf("new thread is created ... \n");
    return (void *)8;
}
int main(int argc,char *argv[])
{
    pthread_t tid;
    int error;
    void *temp;
    error = pthread_create(&tid, NULL, create, NULL);
    if( error )
    {
        printf("thread is not created ... \n");
    &n


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

【Linux桌面应用】Linux服务配置过程

1)关闭防火墙
#service iptables stop<enter> \\关闭防火墙
#chkconfig iptables off<enter> \\关闭开机启动
2)IP地址的配置
①命令方式
#netconfig<enter>  \\设置IP地址、子网掩码、网关、DNS
#vi /etc/sysconfig/network \\主机名
#hostname XXX   \\设置主机名称
#exit  ......

linux设备驱动程序——网络设备驱动程序

Linux的网络系统主要是基于BSD Unix 的socket机制, 访问网络设备的驱动程序不需要使用设备节点。在系统和驱动程序之间定义有专门的数据结构(sk_buff)进行数据的传递。系统内部支持对发送数据和接收数据的缓存,提供流量控制机制,提供对多协议的支持。因此,选择哪个驱动程序是基于内核内部的其他决定,而不是调用open() ......

Linux系统dameon程序的core dump设置

To enable dumps for every daemon:

ulimit -c unlimited >/dev/null 2>&1 (-c maximum size of core files)
ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1

Dump for system
:
DAEMON_COREFILE_LIMIT='unlimited'

The same for every daemon (in /etc/sysconfig/_daemon_ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号