2014年7月20日

Ubuntu切换到root账户

摘要: 使用命令sudo su或sudo -i然后输入密码就可以切换到root帐号,exit可以退出。 阅读全文

posted @ 2014-07-20 19:25 lakeone 阅读(207) 评论(0) 推荐(0) 编辑

RTTI之typeid运算符

摘要: 1 #include 2 #include 3 #include 4 #include 5 6 using std::cout; 7 class Grand 8 { 9 private:10 int hold;11 public:12 Gr... 阅读全文

posted @ 2014-07-20 16:59 lakeone 阅读(322) 评论(0) 推荐(0) 编辑

RTTI之dynamic_cast运算符

摘要: #include #include #include using std::cout;class Grand{ private: int hold; public: Grand(int h=0):hold(h){} virtual void Speak() const {cout Speak(... 阅读全文

posted @ 2014-07-20 16:32 lakeone 阅读(230) 评论(0) 推荐(0) 编辑

2014年6月17日

多线程异步管理——信号

摘要: #include #include #include #include #include void *sigone_program(void *arg);void *sigtwo_program(void *arg);void report(int);int main(int argc,char *... 阅读全文

posted @ 2014-06-17 10:09 lakeone 阅读(359) 评论(0) 推荐(0) 编辑

2014年6月16日

多线程读写锁机制

摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 static pthread_rwlock_t rwlock; 7 #define WORK_SIZE 1024 8 char work_area[WORK_... 阅读全文

posted @ 2014-06-16 11:24 lakeone 阅读(255) 评论(0) 推荐(0) 编辑

线程的互斥锁和条件变量通信机制

摘要: 1 #include 2 #include 3 #include 4 #include 5 6 #define BUFFER_SIZE 2 7 struct prodcons 8 { 9 int buffer[BUFFER_SIZE]; 10 pthre... 阅读全文

posted @ 2014-06-16 09:08 lakeone 阅读(309) 评论(0) 推荐(0) 编辑

2014年6月15日

线程同步机制之互斥锁通信机制

摘要: #include #include #include #include void *thread_function(void *arg);pthread_mutex_t work_mutex;#define WORK_SIZE 1024char work_area[WORK_SIZE];int ti... 阅读全文

posted @ 2014-06-15 17:35 lakeone 阅读(354) 评论(0) 推荐(0) 编辑

线程共享全局变量和私有全局变量

摘要: 共享全局变量实例:#include #include #include #include int key=100;void *helloworld_one(char *argc){ printf("the message is %s\n",argc); key=10; printf... 阅读全文

posted @ 2014-06-15 16:27 lakeone 阅读(2978) 评论(0) 推荐(0) 编辑

线程退出前操作

摘要: #include #include #include #include void cleanup(){ printf("cleanup\n");}void *test_cancel(void){ pthread_cleanup_push(cleanup,NULL); printf(... 阅读全文

posted @ 2014-06-15 11:47 lakeone 阅读(185) 评论(0) 推荐(0) 编辑

Linux下线程pid和tid

摘要: #include #include #include #include struct message{ int i; int j;};void *hello(struct message *str){ printf("child, the tid=%lu, pid=%d\n",pt... 阅读全文

posted @ 2014-06-15 09:29 lakeone 阅读(31597) 评论(0) 推荐(1) 编辑

导航