文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > Linux多线程编程
侵权投诉

Linux多线程编程

echnique called copy-on-write, which avoids a copy of the parent's data space

to the child until the child needs its own copy. But, regardless of this optimization, fork is expensive.

IPC is required to pass information between the parent and child after the fork. Passing information from the parent to the child before the fork is easy, since the child starts with a copy of the parent's data space and with a copy of all the parent's descriptors. But, returning information from the child to t

he parent takes more work.

Threads help with both problems. Threads are sometimes called lightweight processes since a thread is "lighter weight" than a process. That is, thread creation can be 10–100 times faster than process creation.

All threads within a process share the same global memory. This makes the sharing of information easy between the threads, but along with this simplicity comes the problem of synchronization.

=============================

3、有关线程操作的函数

#include <pthread.h>

int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(*func) (void *), void *arg);

int pthread_join (pthread_t tid, void ** status);

pthread_t pthread_self (void);

int pthread_detach (pthread_t tid);

void pthread_exit (void *status);

pthread_create用于创建一个线程,成功返回0,否则返回Exxx(为正数)。

pthread_t *tid:线程id的类型为pthread_t,通常为无符号整型,当调用pthread_create成功时,通过*tid指针返回。 const pthread_attr_t *attr:指定创建线程的属性,如线程优先级、初始栈大小、是否为守护进程等。可以使用NULL来使用默认值,通常情况下我们都是使用默认值。 void *(*func) (void *):函数指针func,指定当新的线程创建之后,将执行的函数。 void *arg:线程将执行的函数的参数。如果想传递多个参数,请将它们封装在一

个结构体中。

pthread_join用于等待某个线程退出,成功返回0,否则返回Exxx(为正数)。

pthread_t tid:指定要等待的线程ID

上一页第3页

你可能喜欢

热门文档

相关文档

  • Linux多线程编程手册

    Linux多线程编程手册_IT/计算机_专业资料。Linux多线程编程手册多线程编程指南 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A. ...

  • Linux多线程编程实例解析

    Linux多线程编程实例解析_IT/计算机_专业资料。haoLinux系统下的多线程遵循POSIX线程接口,称为 pthread。编写Linux下的多线程程序,需要使用头文件pthread.h,连接时...

  • linux 下多线程编程 ( C 语言编程)

    linux 下多线程编程 ( C 语言编程)_计算机软件及应用_IT/计算机_专业资料。linux 下多线程编程 ( C 语言编程)linux 下 C 语言多线程编程实例 作者: ...

  • linux多线程编程

    linux多线程编程_IT/计算机_专业资料。linux 进程线程linux多线程编程 1. 2. Linux下 Linux下线程概述 linux线程 linux线程实现 1、Linux下线程概述进程是系统中...

  • Linux多线程编程

    Linux多线程编程_信息与通信_工程科技_专业资料。自己根据网络资料进行的学习总结第八章 嵌入式 Linux 多线程编程 8.1 线程基本概念 8.1.1 Linux 线程简介 ...

  • Linux多线程编程讲稿

    Linux多线程编程讲稿_专业资料。关于Linux的多线程编程介绍博创科技 嵌入互动 第四讲 Linux多线程编程北京博创兴业科技有限公司 北 京 博 创 兴 业 科 技 有...

  • linux多线程编程相关知识

    linux多线程编程相关知识_工学_高等教育_教育专区。linux多线程编程相关知识linux 多线程编程相关知识 进程是系统中程序执行和资源分配的基本单位。每个进程都拥有自己...

  • 关于Linux多线程编程

    关于Linux 多线程编程 Linux 线程分为两类,一是核心级支持线程,在核心级实现线程时,线程的实现依赖于 内核,无论是在用户进程中的线程还是系统进程中的线程,他们...

  • linux下C语言多线程编程实例

    linux下C语言多线程编程实例_计算机软件及应用_IT/计算机_专业资料。linux多线程编程linux 下 C 语言多线程编程实例 2007 年 11 月 29 日 星期四 10:39 学...

  • Linux多线程程序设计

    Linux多线程程序设计_IT/计算机_专业资料。Linux多线程程序设计华南理工大学 陈虎 博士 tommychen74@yahoo.com.cn Linux中的线程 ? Linux上的线程和进程都有独立...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email