随笔分类 -  多线程

摘要:Grand Central Dispatch (GCD) is a technology developed by Apple Inc. to optimize application support for systems with multi-core processors and other  阅读全文
posted @ 2018-01-18 23:51 zzfx 阅读(197) 评论(0) 推荐(0) 编辑
摘要:POSIX Threads, usually referred to as pthreads, is an execution model that exists independently from a language, as well as a parallel execution model 阅读全文
posted @ 2018-01-18 23:49 zzfx 阅读(184) 评论(0) 推荐(0) 编辑
摘要:1)取消点的位置;耗时操作、大的业务逻辑; 2)取消后的资源释放。 pthread_cleanup_push 执行取消操作存在一定的危险。大多数危险都与完全恢复不变量和释放共享资源有关。取消线程时一定要格外小心,否则可能会使互斥保留为锁定状态,从而导致死锁状态。或者,已取消的线程可能保留已分配的内存 阅读全文
posted @ 2017-12-11 19:36 zzfx 阅读(392) 评论(0) 推荐(0) 编辑
摘要:Concurrency and Application Design In the early days of computing, the maximum amount of work per unit of time that a computer could perform was deter 阅读全文
posted @ 2017-12-11 19:21 zzfx 阅读(136) 评论(0) 推荐(0) 编辑
摘要:One of the technologies for starting tasks asynchronously is Grand Central Dispatch (GCD). This technology takes the thread management code you would 阅读全文
posted @ 2017-12-11 19:19 zzfx 阅读(168) 评论(0) 推荐(0) 编辑
摘要:Replacing Threads with Dispatch Queues To understand how you might replace threads with dispatch queues, first consider some of the ways you might be 阅读全文
posted @ 2017-12-11 19:14 zzfx 阅读(180) 评论(0) 推荐(0) 编辑
摘要:Dispatch Queues Dispatch queues are a C-based mechanism for executing custom tasks. A dispatch queue executes tasks either serially or concurrently bu 阅读全文
posted @ 2017-12-11 19:08 zzfx 阅读(267) 评论(0) 推荐(0) 编辑
摘要:应用崩溃时,崩溃线程一定有重要线索保留。正如谋杀现场,当事人和被害者已经交互细节需要保留一样。 应用崩溃现场需要保存和还原的信息分为三个方面: 1)硬件环境:主要是cpu位数和其他信息; 2)进程信息:主要是进程标示符号; 3)线程信息,也就是线程执行是的上下文环境。比较主要的指标是(1)函数调用栈 阅读全文
posted @ 2017-11-24 17:27 zzfx 阅读(197) 评论(0) 推荐(0) 编辑
摘要:In computing, a context switch is the process of storing and restoring the state (more specifically, the execution context) of a process or thread so 阅读全文
posted @ 2017-11-24 17:07 zzfx 阅读(175) 评论(0) 推荐(0) 编辑
摘要:1)线程存在的目的:提高cpu的使用效率; 2)线程实现模型:用户线程、内核线程; 3)线程谁在持有:内核维护线程列表、进程维护线程列表、应用维护线程池; 4)线程的数据结构属性:tcb结构、线程属性结构等; 5)线程的运行时:调度与切换; 6)线程的业务与数据侧面:本质上是数据处理流; 7)线程的 阅读全文
posted @ 2017-11-24 16:56 zzfx 阅读(146) 评论(0) 推荐(0) 编辑
摘要:作者:阿波链接:http://blog.csdn.net/livelylittlefish/article/details/7918110 (整半年没有更新,发几篇以前的读书笔记。) Content 1. 基础概念 2. 线程安全 3. 可重入 4. 并发系统基本功能 1. 基础概念 线程 进程里执 阅读全文
posted @ 2017-11-24 16:27 zzfx 阅读(230) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/gatieme/article/details/51892437 之前讲解过内核线程、轻量级进程、用户线程三种线程概念解惑(线程≠轻量级进程), 但是一直对其中提到的线程的实现模型比较迷惑, 这次就花了点时间怎么学习了一下子 1 线程的3种实现方式 在传统的 阅读全文
posted @ 2017-11-24 15:45 zzfx 阅读(5480) 评论(2) 推荐(2) 编辑
摘要:结论:线程崩溃不一定导致进程崩溃。 线程崩溃的本质就是内存出错。而内存出错有时不会引起其他线程出错的,因为崩溃的线程,也就是出错的内存有时侯没有被其他线程访问,也就不会产生问题,但有时候会打乱其他线程的内存。 https://bbs.csdn.net/topics/330102295 阅读全文
posted @ 2017-11-23 16:47 zzfx 阅读(3176) 评论(0) 推荐(1) 编辑
摘要:http://www.cocoachina.com/ios/20151103/14007.html 本文翻译自 Ryan Kaplan 的 More than you want to know about @synchronized 因为原文一些内容写的不太准确,我按照我的理解做出了批注和补充。 如 阅读全文
posted @ 2017-07-25 12:10 zzfx 阅读(848) 评论(0) 推荐(0) 编辑
摘要:mutex:为了保护条件变量而存在的; cond:为了线程通信而存在的。 整个机制都是为了保护条件变量和线程间通信而存在的。 pthread_cond_wait()函数一进入wait状态就会自动release mutex pthread_cond_wait() 一旦wait成功获得cond 条件的时 阅读全文
posted @ 2017-06-20 19:16 zzfx 阅读(162) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/u013234805/article/details/24796551 Futex是fast userspacemutex的缩写,意思是快速用户空间互斥体。它由HubertusFranke,MatthewKirkwood,IngoMolnar和RustyRu 阅读全文
posted @ 2017-06-20 18:35 zzfx 阅读(590) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/rsyp2008/article/details/45150621 1 线程ID获取方法 Linux下获取线程有两种方法: 1)gettid或者类似gettid的方法 2)直接调用pthread_self() gettid 获取的是内核中线程ID,而pthr 阅读全文
posted @ 2017-06-19 11:39 zzfx 阅读(1014) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/zsf8701/article/details/7842392 //线程属性结构如下:typedef struct{ int etachstate; //线程的分离状态 int schedpolicy; //线程调度策略 structsched_param 阅读全文
posted @ 2017-05-21 00:21 zzfx 阅读(280) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/qq_27231343/article/details/52562196 那么过多的递归调用为什么会引起栈溢出呢?事实上,函数调用的参数是通过栈空间来传递的,在调用过程中会占用线程的栈资源。而递归调用,只有走到最后的结束点后函数才能依次退出,而未到达最后的结 阅读全文
posted @ 2017-05-21 00:04 zzfx 阅读(2878) 评论(0) 推荐(0) 编辑
摘要:一、线程的双重属性: 1)结构体(对象)属性: 2)task属性;对应业务流程。 对象属性:面向api,面向编程; task属性面向cpu。 线程的对象属性的作用: 1)为任务的执行提供进程以外的上下文; 2)定义执行流的属性及控制功能; 阅读全文
posted @ 2017-05-03 23:32 zzfx 阅读(322) 评论(0) 推荐(0) 编辑