07 2014 档案
摘要:https://www.ibm.com/developerworks/cn/linux/thread/posix_threadapi/part4/http://www.cnblogs.com/xfiver/archive/2013/01/23/2873725.html线程终止方式一般来说,Posix...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 6 static void checkResults(char *string, int rc) { 7 if (rc) { 8 printf("Error on : %s,...
阅读全文
摘要:-static 此选项将禁止使用动态库,所以,编译出来的东西,一般都很大,也不需要什么动态连接库,就可以运行.-share 此选项将尽量使用动态库,所以生成文件比较小,但是需要系统由动态库.
阅读全文
摘要:http://ifeve.com/mutex-and-memory-visibility/POSIX内存可见性规则IEEE 1003.1-2008定义了XBD 4.11内存同步中的内存可见性规则。特别地,POSIX实现保证:pthread_create()同步:任何变量在pthread_create...
阅读全文
摘要:转载 http://blog.csdn.net/yusiguyuan/article/details/14161225线程间的同步技术,主要以互斥锁和条件变量为主,条件变量和互斥所的配合使用可以很好的处理对于条件等待的线程间的同步问题。举个例子:当有两个变量x,y需要在多线程间同步并且学要根据他们之...
阅读全文
摘要:http://www.blogjava.net/fhtdy2004/archive/2009/07/05/285519.html线程同步:何时互斥锁不够,还需要条件变量?很显然,pthread中的条件变量与Java中的wait,notify类似假设有共享的资源sum,与之相关联的mutex 是loc...
阅读全文
摘要:许多互斥对象如果放置了过多的互斥对象,代码就没有什么并发性可言,运行起来也比单线程解决方案慢。如果放置了过少的互斥对象,代码将出现奇怪和令人尴尬的错误。幸运的是,有一个中间立场。首先,互斥对象是用于串行化存取*共享数据*。不要对非共享数据使用互斥对象,并且,如果程序逻辑确保任何时候都只有一个线程能存...
阅读全文
摘要:refhttp://www.ibm.com/developerworks/cn/linux/thread/posix_thread1/index.html 1 #include 2 #include 3 #include 4 #include 5 int myglobal; 6 void ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 6 7 void *thread_foo_func(void *); 8 void *thread_bar_func(void *); 9 10 11 int global = 4;12 13 ...
阅读全文
摘要:转子http://www.ibm.com/developerworks/cn/linux/kernel/l-thread/二.Linux 2.4内核中的轻量进程实现最初的进程定义都包含程序、资源及其执行三部分,其中程序通常指代码,资源在操作系统层面上通常包括内存资源、IO资源、信号处理等部分,而程序...
阅读全文
摘要:NPTL是一个1×1的线程模型,即一个线程对于一个操作系统的调度进程,优点是非常简单。而其他一些操作系统比如Solaris则是MxN的,M对应创建的线程数,N对应操作系统可以运行的实体。(Ntgid;957 }1100 asmlinkage long sys_gettid(void)1101 {11...
阅读全文
摘要:内核线程是直接由内核本身启动的进程。内核线程实际上是将内核函数委托给独立的进程,与系统中其他进程“并行”执行(实际上,也并行于内核自身的执行),内核线程经常被称为内核“守护进程”。它们主要用于执行下列任务:l 周期性地将修改的内存页与页来源块设备同步。l 如果内存页很少使用,则写入交换区。l 管理延...
阅读全文
摘要:Linux 线程实现机制分析http://www.ibm.com/developerworks/cn/linux/kernel/l-thread/上面文章分析的非常透彻按照教科书上的定义,进程是资源管理的最小单位,线程是程序执行的最小单位。在操作系统设计上,从进程演化出线程,最主要的目的就是更好的支...
阅读全文
摘要:转载请注明出处:http://blog.csdn.net/ns_code/article/details/17284351进程(线程)之间的两种关系:同步与互斥。所谓互斥,是指三部在不同进程之间的若干程序片断,当某个进程运行其中一个程序片段时,其它进程就不能运行它们之中的任一程序片段,只能等到该进程...
阅读全文
摘要:转载 http://www.cnblogs.com/caosiyang/archive/2012/06/25/2560976.html简单说一下popen()函数函数定义1 #include 2 3 FILE * popen(const char *command , const char *typ...
阅读全文
摘要:多数引用http://www.dreamdu.com/xhtml/novice/ 欢迎来到梦之都 这是我的第一个网页,在这里 尽情学习HTML 吧! ...
阅读全文
摘要:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
阅读全文
摘要:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv...
阅读全文
摘要:分析转载 http://blog.csdn.net/joylnwang/article/details/6859677Find the contiguous subarray within an array (containing at least one number) which has the...
阅读全文
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol...
阅读全文
摘要:Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl...
阅读全文
摘要:Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol...
阅读全文
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.思路:动态规划:f[i][j] 表示在第i行中以(i,j)点结束点...
阅读全文
摘要:将Best Time to Buy and Sell Stock的如下思路用到此题目思路1:第i天买入,能赚到的最大利润是多少呢?就是i + 1 ~ n天中最大的股价减去第i天的。思路2:第i天买出,能赚到的最大利润是多少呢?就是第i天的价格减去0~ i-1天中最小的。和前两道题比起来的话,这道题最...
阅读全文
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
阅读全文
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
阅读全文
摘要:Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed...
阅读全文
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
阅读全文
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ...
阅读全文