摘要: 本文缘起于最近几天笔者实现的一段代码,目的是利用 python 在 Linux 中实现一个常驻内存的后台守护进程负责向其他进程提供服务,起初笔者自信的认为 multiprocessing.Process 类的 daemon 属性应该符合要求,于是乎不假思索的挥毫写下测试代码如下: 1 2 3 4 5 阅读全文
posted @ 2017-05-19 14:37 roadmap 阅读(616) 评论(0) 推荐(1)
摘要: 死锁(deadlock) 是指两个或两个以上的进程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去。此时称系统处于死锁状态或系统产生了死锁,这些永远在互相等待的进程称为死锁进程。 虽然进程在运行过程中,可能发生死锁,但死锁的发生也必须具备一定的条件,死锁的发生必 阅读全文
posted @ 2017-05-17 18:26 roadmap 阅读(1419) 评论(0) 推荐(0)
摘要: 总结一下C语言中宏的一些特殊用法和几个容易踩的坑。由于本文主要参考GCC文档,某些细节(如宏参数中的空格是否处理之类)在别的编译器可能有细微差别,请参考相应文档。 宏基础 宏仅仅是在C预处理阶段的一种文本替换工具,编译完之后对二进制代码不可见。基本用法如下: 1. 标示符别名 #define BUF 阅读全文
posted @ 2017-05-17 18:23 roadmap 阅读(3024) 评论(0) 推荐(0)
摘要: 1,防止一个头文件被重复包含 #ifndef BODYDEF_H #define BODYDEF_H //头文件内容 #endif 2,得到指定地址上的一个字节或字 #define MEM_B( x ) ( *( (byte *) (x) ) ) #define MEM_W( x ) ( *( (w 阅读全文
posted @ 2017-05-17 18:16 roadmap 阅读(495) 评论(0) 推荐(0)
摘要: 一幅图让你彻底理解KMP算法(转) http://v.atob.site/kmp-next.html KMP算法最难理解的莫过于next数组。为什么在p[j]!=p[k]时,需要将k赋值为next[k]?通过一副图分析了KMP算法中next数组的计算原理,指出next[k]表示的就是字符串长度为k的 阅读全文
posted @ 2017-05-16 12:10 roadmap 阅读(187) 评论(0) 推荐(0)
摘要: #include <stdio.h>#include <stdlib.h>#include <string.h> template <class T_ELE>class Vector { private: unsigned int m_size; unsigned int m_stride; uns 阅读全文
posted @ 2017-04-27 23:12 roadmap 阅读(169) 评论(0) 推荐(0)
摘要: #include <stdio.h>#include "stdafx.h"struct Person {public: int age; Person() { this->age = 0; } Person(int age);};Person::Person(int age){ this->age 阅读全文
posted @ 2017-04-26 23:08 roadmap 阅读(89) 评论(0) 推荐(0)
摘要: #include <stdio.h>#include "stdafx.h"struct BigNumber {private: unsigned int low; unsigned int high;public: BigNumber(int x, int y) { this->low = x; t 阅读全文
posted @ 2017-04-26 22:56 roadmap 阅读(140) 评论(0) 推荐(0)
摘要: #include <stdio.h>struct node_s {private: int x; int y;public: node_s(int x, int y) { this->x = x; this->y = y; } friend struct node_s1;};struct node_ 阅读全文
posted @ 2017-04-26 22:27 roadmap 阅读(111) 评论(0) 推荐(0)
摘要: #include <stdio.h>struct node_s {private: int x; int y;public: node_s(int x, int y) { this->x = x; this->y = y; } friend void print(node_s &p);};void 阅读全文
posted @ 2017-04-26 22:22 roadmap 阅读(147) 评论(0) 推荐(0)