上一页 1 ··· 45 46 47 48 49 50 51 52 53 ··· 100 下一页

2013年5月9日

posix多线程有感--自旋锁

摘要: 自旋锁是SMP架构中的一种low-level的同步机制。 当线程A想要获取一把自旋锁而该锁又被其它线程锁持有时,线程A会在一个循环中自旋以检测锁是不是已经可用了。对于自选锁需要注意:由于自旋时不释放CPU,因而持有自旋锁的线程应该尽快释放自旋锁,否则等待该自旋锁的线程会一直在那里... 阅读全文

posted @ 2013-05-09 19:54 胡永光 阅读(188) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(线程内存模式)

摘要: 一组并发线程运行在一个进程的上下文中,每个线程都有自己独有的线程上下文,上下文中包括线程ID,栈,栈指针,程序计数器,条件代码和通用寄存器值,每个线程与其他线程共享部分进程上下文,其中包括整个虚拟地址空间(这个空间有只读文本(代码)区),读/写数据区,堆和所有共享库代码和数据区,线程也同样共... 阅读全文

posted @ 2013-05-09 17:10 胡永光 阅读(99) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(条件变量属性)

摘要: 1.条件变量的初始化int pthread_cond_init(thread_cond_t *cond,pthread_condattr_t *attr); 参数:cond 条件变量 attr 条件变量属性 成功返回0,出错返回错误编号。 注意:如果参数att... 阅读全文

posted @ 2013-05-09 15:36 胡永光 阅读(140) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(互斥量属性)(代码)

摘要: /* * mutex_attr.c * * Create a mutex using a non-default attributes object, * mutex_attr. If the implementation supports the pshared * attribute, the... 阅读全文

posted @ 2013-05-09 09:58 胡永光 阅读(156) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(互斥量属性)

摘要: 互斥量具有一些属性,通过修改这些属性可以控制锁的一些行为。缺省的互斥锁属性及其值如下:pshared: PTHREAD_PROCESS_PRIVATEtype: PTHREAD_MUTEX_DEFAULTprotocol: PTHR... 阅读全文

posted @ 2013-05-09 09:51 胡永光 阅读(164) 评论(0) 推荐(0) 编辑

2013年5月8日

posix多线程有感--线程高级编程(线程属性函数总结)(代码)

摘要: /* * thread_attr.c * * Create a thread using a non-default attributes object, * thread_attr. The thread reports its existence, and exits. The * attri... 阅读全文

posted @ 2013-05-08 11:47 胡永光 阅读(160) 评论(0) 推荐(0) 编辑

2013年5月7日

posix多线程有感--线程高级编程(线程属性函数总结)

摘要: pthread_attr_t 的缺省属性值 属性 值 结果 scope PTHREAD_SCOPE_PROCESS 新线程与进程中的其他线程发生竞争。 detachstate PTHREAD_CREATE_JOINABLE 线程退出后,保留完成状态和线程... 阅读全文

posted @ 2013-05-07 23:34 胡永光 阅读(201) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(线程属性pthread_attr_t)---实时调度(代码)

摘要: /* * sched_attr.c * * Demonstrate use of POSIX 1003.1c-1995 thread priority * scheduling attributes, by creating an attributes object with * realtime... 阅读全文

posted @ 2013-05-07 17:20 胡永光 阅读(190) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(线程属性pthread_attr_t)---实时调度

摘要: 一、系统支持的线程优先级的最大和最小值名称::sched_get_priority_maxsched_get_priority_min功能:获得系统支持的线程优先权的最大和最小值头文件:#include函数原形:int sched_get_priority_max(int policy);int ... 阅读全文

posted @ 2013-05-07 17:17 胡永光 阅读(339) 评论(0) 推荐(0) 编辑

posix多线程有感--线程高级编程(线程属性pthread_attr_t)

摘要: 1.线程属性 线程具有属性,用pthread_attr_t表示,在对该结构进行处理之前必须进行初始化,在使用后需要对其去除初始化。我们用pthread_attr_init函数对其初始化,用pthread_attr_destroy对其去除初始化。名称::pthread_attr_init... 阅读全文

posted @ 2013-05-07 16:25 胡永光 阅读(192) 评论(0) 推荐(0) 编辑

上一页 1 ··· 45 46 47 48 49 50 51 52 53 ··· 100 下一页

导航