摘要: #include <iostream>#include<unistd.h>#include<sys/types.h>using namespace std;int main(){int i;if (fork() == 0){/* 子进程程序 */for (i = 1; i < 1000; i++)cout<<"子进程"<<i<<endl;}else{/* 父进程程序*/for (i = 1; i < 1000; i++)cout<<"父进程"<<i 阅读全文
posted @ 2012-03-15 16:04 byfei 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Linux下一个进程在内存里有三部份的数据,就是“数据段”,“堆栈段”和“代码段”,其实学过汇编语言的人一定知道,一般的CPU象I386,都有上述三种段寄存器,以方便操作系统的运行。“代码段”,顾名思义,就是存放了程序代码的数据,假如机器中有数个进程运行... 阅读全文
posted @ 2012-03-15 15:47 byfei 阅读(62) 评论(0) 推荐(0) 编辑
摘要: Linux下一个进程在内存里有三部份的数据,就是“数据段”,“堆栈段”和“代码段”,其实学过汇编语言的人一定知道,一般的CPU象I386,都有上述三种段寄存器,以方便操作系统的运行。“代码段”,顾名思义,就是存放了程序代码的数据,假如机器中有数个进程运行相同的一个程序,那么它们就可以使用同一 个代码段。 堆栈段存放的就是子程序的返回地址、子程序的参数以及程序的局部变量。而数据段则存放程序的全局变量,常数以及动态数据分配的数据空间(比如用malloc之类的函数取得的空间)。这其中有许多细节问题,这里限于篇幅就不多介绍了。系统如果同时运行数个相同的程序,它们之间就不能使用同一个堆栈段和... 阅读全文
posted @ 2012-03-15 15:46 byfei 阅读(221) 评论(0) 推荐(0) 编辑
摘要: #include <pthread.h>vector<uint> m_vectSelectDataHander;typedef map<int, int> templatemap;templatemap MapPthreadID;void *thread1(void*){int nPthread = MapPthreadID[pthread_self()];}for(int i=0;i<n;i++)m_vectSelectDataHander.push_back(0);for(uint i = 0; i < m_vectSelectDataHan 阅读全文
posted @ 2012-03-15 14:57 byfei 阅读(208) 评论(0) 推荐(0) 编辑
摘要: #include vector m_vectSelectDataHander;typedef map templatemap;templatemap MapPthreadID;void *thread1(void*){ int nPthread = MapPt... 阅读全文
posted @ 2012-03-15 14:57 byfei 阅读(26) 评论(0) 推荐(0) 编辑