博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 16 下一页

2011年5月27日

摘要: Mutex:所有线程进行竞争。被Mutex锁住的资源,要么被锁住,要么不被锁住。不会有其他情况。 ReaderWriter Lock:有三种状态,read lock, write lock, unlock。read lock可以多个线程共享,write lock只能一个线程使用。 这两个锁的共同特点:MUST intitialized before use, destroyed before fr... 阅读全文

posted @ 2011-05-27 11:29 天地玄黄 阅读(173) 评论(0) 推荐(0)

2011年5月26日

摘要: process使用fork()函数产生一个和父进程一摸一样的子进程。然后再使用exec函数用另一个program代替这个子进程。这样就产生了两个进程。 而thread则使用pthread_create()函数产生一个新的thread,这个thread和以前的thread没有什么上下级的关系,并且它调用的是一个“函数”,不是一个独立的程序。 阅读全文

posted @ 2011-05-26 19:54 天地玄黄 阅读(286) 评论(0) 推荐(0)

摘要: 在Linux中使用线程相关的东西就要使用到这个头文件,但这还不算。如果仅仅使用这个头文件,会出现错误: undefined reference to `pthread_create'collect2: ld returned 1 exit statusmake: *** [threadid] Error 1 之所以出现这样的错误,是因为我们没有链接相应的函数库。所以在编译的时候要加上 –lpth... 阅读全文

posted @ 2011-05-26 14:55 天地玄黄 阅读(12056) 评论(0) 推荐(1)

摘要: 和 threads 相关的信息: · thread ID · register value · a stack · scheduling priority and policy · signal mask · errno variable · thread-specific data 很多threads 所共享的东西: · .text · global and heap memory · stac... 阅读全文

posted @ 2011-05-26 14:08 天地玄黄 阅读(247) 评论(0) 推荐(0)

摘要: 1、在Unix系统中,signal是可以随时出现的。因此,Unix中的process就告诉kernel “如果出现signal,就去做下面这些事情”。 2、signal 是由谁发出的:terminal-generated signals, hardware exceptions, kill(2) function, kill(1) command, software condition sign... 阅读全文

posted @ 2011-05-26 13:56 天地玄黄 阅读(261) 评论(0) 推荐(0)

2011年5月16日

摘要: 在C语言中,函数名竟然可以和struct类型名相同。看下面的程序。定义了struct foo; 和 void foo(struct foo *)两个函数。 #include <stdio.h>struct foo { int a; int b;};void foo(struct foo *f){ printf("%d, %d", f->a, f->b);}int main(){ struct f... 阅读全文

posted @ 2011-05-16 15:12 天地玄黄 阅读(1604) 评论(0) 推荐(0)

2011年5月13日

摘要: 原文网址:http://uw714doc.sco.com/en/SDK_sysprog/_The_Controlling-Terminal_and_Pr.html The controlling-terminal and process-groups A terminal may belong to a process as its controlling-terminal, which is a... 阅读全文

posted @ 2011-05-13 15:30 天地玄黄 阅读(390) 评论(0) 推荐(0)

2011年5月6日

摘要: 原文网址:http://www.adp-gmbh.ch/cpp/gcc/create_lib.html 还是看原文吧,不要看下面了,原文中有各种格式。 Here's a summary on how to create a shared and a static library with gcc. The goal is to show the basic steps. I do not want... 阅读全文

posted @ 2011-05-06 16:05 天地玄黄 阅读(400) 评论(0) 推荐(0)

摘要: 一个C语言的可执行程序(a.out)通常被分成以下几个部分: · Text segment: 即汇编中的.text segemnt。machine instruction, sharable, only one copy in memory, read-only · Initialized data: 即汇编中的.data segment。是已经初始化的数据。是出现在所有的程序之外的变量(全局变量... 阅读全文

posted @ 2011-05-06 15:28 天地玄黄 阅读(388) 评论(0) 推荐(0)

摘要: 一般我们写main函数都是这样的: int main(int argc, char **argv); 一个process调用exec函数给新的将要执行的program传递command-line argument。(When a program is executed, the process that does the “exec” can pass command-line argument... 阅读全文

posted @ 2011-05-06 14:53 天地玄黄 阅读(171) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 16 下一页