易截截图软件、单文件、免安装、纯绿色、仅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编程(六) L2CAP编程实例

例一:发送Signaling Packet:
Signaling Command是2个Bluetooth实体之间的L2CAP层命令传输。所以得Signaling Command使用CID 0x0001.
多个Command可以在一个C-frame(control frame)中发送。
 如果要直接发送Signaling Command.需要建立SOCK_RAW类型的L2CAP连接Socket。这样才有机会自己填充Command Code,Identi ......

Linux下的库

Linux下的库--重要的代码复用机制【转】
2008-03-26 17:57
本文主要解决以下几个问题
1 为什么要使用库?
2 库的分类
3 创建自己的库
或许大家对自己初学
linux时的情形仍记忆尤新吧。如果没有一个能较好的解决依赖关系的包管理器,在linux下安装软件将是一件及其痛苦的工作。你装a包时,可能会提示
你要先装b包, ......

嵌入式Linux下彩色LCD驱动的设计与实现

嵌入式Linux下彩色LCD驱动的设计与实现
摘要:本文介绍了如何在嵌入在开发彩色LCD显示驱动的方法,并对Linux中的显示驱动程序结构和框架作一介绍。
    长期以来,在常见的掌上电脑(PDA)等小型手持式设备上,由于硬件条件等的限制,我们看到的显示器件通常是单色LCD,用户界面也非常简单,几乎看不到 PC ......

How to: Linux flush or remove all iptables rules

 
Here is small script that does this. Debian or Ubuntu GNU/Linux does
not comes with any SYS V init script (located in /etc/init.d directory)
.
You create a script as follows and use it to stop or flush the iptables rules.
Please don't type rules at command prompt. Use the script to sp ......

初学Linux积累。

2009-10-27
1,重启 reboot
2009-10-28
1,忘记了root用户密码的解决帮
启动后按esc进入修复模式,选择修复,并选择最后一个。root,进去后,更改密码:passwd root
然后根据提示输入两次密码就行了。
2009-10-29
1,ls
    ls -a 查看所有文件
    ls -l 查看详细的属性
 &nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号