- 博客(31)
- 资源 (8)
- 收藏
- 关注
转载 c++ template (总结)
模板中:typename作为嵌套从属类型名称的前缀词。例外:不可以出现在初始值列 和 base class list中。有的编译器不支持子类调用基类的函数(VC2005支持),需要加this->,或using,或classname直接指定;一、函数模板1)分类:1. 成员函数模板:成员函数通过模板传变参。
2012-09-27 12:27:52 9658 1
原创 C++ new delete new[] delete[]
C++不支持类专属的new-handler,类需要自定义operator new和set_new_handler静态成员函数来使用其专属的new-handler。throwing (1)void* operator new (std::size_t size) throw (std::bad_alloc);nothrow (2) void* operator new (std::s
2012-09-24 16:49:52 742
转载 类型转换
不要对数组使用多态语言规范中说通过一个基类指针来删除一个含有派生类对象的数组,结果将是不确定的。这实际意味着执行这样的代码肯定不会有什么好结果。多态和指针算法不能混合在一起来用,所以数组与多态也不能用在一起。 谨慎定义类型转换函数有两种函数允许编译器进行这些的转换:单参数构造函数(single-argument constructors)和隐式类型转换运算符。隐式类型转
2012-09-21 15:05:53 446
原创 中断
一、与“异常”的关系中断是由硬件引起;异常:如÷零,缺页等,需要内核来处理时,处理器会产生一个异常。为处理器本身产生的同步中断;二、中断与BH中断处理程序是上半部 top half。bottom half目前有几种:软中断,tasklet,工作队列。三、request_irq注册的软件中断号的中断处理;而通过irq_create_mapping来
2012-09-17 17:03:19 523
转载 内核同步方法
原子操作spinlock --- 忙等待,不释放cpu。所以用于短时间加锁。 用于中断处理程序时,要同时禁止本地中断。即使用spin_lock_irqsaverwlock --- 比较照顾读锁情况。信号量 --- 得不到信号,就会引起进程休眠rw信号量互斥体 --- 就是可以休眠的
2012-09-17 11:22:50 567
原创 内核线程 + 下半部(软中断,工作队列)
下半部目前包括软中断,tasklet,工作队列。软中断: 编译器静态分配的; 不互相抢占; 只有中断处理程序可以抢占它; 相同类型软中断可以在不同的CPU上同时运行; 大部分软中断处理程序都通过采取单处理器数据或其他技巧来避免加锁。tasklet: 建立在软中断之上; 可以动态生成;
2012-09-15 19:09:36 2177
原创 linux 进程调度 (update)
参考Robert love的著作:2.6内核版本以后的linux实现了抢占式内核,实现了内核抢占。进程调度顺序:1. 实时进程 > 非实时进程2. 实时进程之间,比较实时优先级,1到99,越大越高。3. 实时优先级相同的实时进程之间,根据调度策略来执行。分FIFO和RR两种。 1)其中RR方式,是轮询的,在3.5.3内核版本中,rt_sched
2012-09-13 00:32:18 1214
原创 红黑树
使用案例: 如 linux内核中,完全公平调度策略CFS的运行队列 使用"红黑树"方法管理进程。红黑树是“半平衡二叉树”!效率好!!!//因为:树里面最长路径不会大于最短路径的两倍。使用rb_entry、rb_insert_color、rb_erase等。linux代码关键结构体如下:struct rq { ----
2012-09-12 17:54:26 799
原创 UML 关联, 聚合, 组合
http://justsee.iteye.com/blog/808799http://www.360doc.com/content/07/0612/11/16903_553244.shtmlhttp://www.360doc.com/content/11/1226/16/8426246_175119248.shtmlUML设计类中,类的关系分为Generalization(
2012-09-12 17:08:06 775
原创 strpbrk strspn strcspn
1、strpbrk#include char *strpbrk(const char *s, const char *accept);accept是一组字符,在s中查找此组字符中的任意一个,匹配即停止并返回指针指向此字符位置。如strpbrk(s, “+="); 表示s中匹配到+号或=号都停止。 2、strspn,strcspn#include si
2012-09-07 15:18:37 1126
原创 粗析openssh 中scp代码逻辑
scp.c中main 基本流程1、解析参数;2、根据"最后的参数"看是本地copy,还是远程copy。 分别指向toremote和tolocal函数。3、toremote()分三种:(和下面分析的流程类似,请参考最下面的彩色字体描述) 1)远端到远端,通过本地。(分解为两步:远端到本地,本地到远端) 2)远端到远端,不通过本地
2012-09-07 15:12:36 3407
原创 ssh scp
ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-e escape_char] [-F configfile] [-i identity_file] [-L [bind_address:]port:host:hostport] [-l lo
2012-09-06 15:37:57 922
原创 execve, execl, execlp, execle, exece, execvp
http://www.kernel.org/doc/man-pages/online/pages/man3/exec.3.html #include int execve(constchar*filename,char*constargv[],char*constenvp[]); 只有此函数是系统调用。其他都是C库。 1. filename是可执行文件,或者是
2012-09-06 15:27:23 1520
翻译 getopt, optarg, optind, opterr, optopt
http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html #include int getopt(int argc, char * const argv[], const char *optstring); extern char *opta
2012-09-06 13:39:43 6522
原创 网址 IETF 3GPP 3GPP2 OMA 道客巴巴 维基百科 IEEE ITU
专业网址:http://www.ietf.org/rfc.htmlhttp://www.3gpp.org/http://www.3gpp.org/specs/specs.htmhttp://www.3gpp.org/ftp/Specs/archive/http://www.3gpp2.org/Public_html/specs/http://www.openmobile
2012-09-06 09:31:37 2332
原创 linux 文件I/O API
1. 文件描述符使用int,而不是unix中的fd_t.2. STDIN_FILENO,STDOUT_FILENO,STDERR_FILENO3.open int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode); 只有
2012-09-05 23:31:59 557
翻译 C UNIX标准
http://man7.org/linux/man-pages/man7/standards.7.html 各个组织都退出自己的标准:1、贝尔实验室V7 2、BSD推出的:4.2BSD -》 4.3BSD -》4.4BSD 3、AT&TSystem V -》System V release 2 -》SVr3 -》SVr4 4、ISOC89
2012-09-05 23:26:12 999
原创 errno perror strerror strerror_r
http://man7.org/linux/man-pages/man3/errno.3.html 1、当系统调用或一些C库函数出错时,设置errno。 2、errno永远不会被系统调用或库函数设置为0. 调用成功时,errno行为未知,可能被修改。 3、一般情况下,系统调用或库函数出错时,返回-1或NULL。但有些情况下,返回-1就是正常值,如getp
2012-09-05 22:58:50 3243
翻译 openssh历史
http://www.openssh.com openssh是一套软件,用ssh替代了rlogin,telnet;用scp替代了rcp;用sftp替代了ftp。而且还要其他组件,如sshd, ssh-add, ssh-agent, ssh-keysign, ssh-keyscan, ssh-keygen and sftp-server。 openssh ve
2012-09-05 21:10:26 794
原创 命令查询网址
linux命令查询http://man7.org/linux/man-pages/index.html openbsd的命令查询(一种unix系统)http://www.openbsd.org/cgi-bin/man.cgi
2012-09-05 20:58:46 644
翻译 linux进程通信之pipe (pipe,pipe2)
http://man7.org/linux/man-pages/man2/pipe.2.html #include int pipe(int pipefd[2]); #define _GNU_SOURCE #include int pipe2(int pipefd[2], int flags); /
2012-09-05 15:22:20 10400
翻译 va_list,va_start,va_end,va_copy,vprintf,vfprintf,vsprintf,vsnprintf
#include int printf(const char *format, ...); int fprintf(FILE *stream, const char *format, ...); int sprintf(char *str, const char *format, ...); int snprintf(char
2012-09-05 14:26:49 1484
翻译 MAN (FDDI, ATM, SDH, MPLS)
http://en.wikipedia.org/wiki/Metropolitan_area_networkhttp://en.wikipedia.org/wiki/Synchronous_optical_networking等。Asynchronous Transfer Mode (ATM), FDDI, and SMDS 等技术正在被城域以太网替代。LAN之间可
2012-09-05 00:17:04 1368
翻译 三网融合
voice on the telephone network, data on computer networks or local area networks (LANs), video teleconferencing on private corporate networks, and television onbroadcast radio or cable networks.电信
2012-09-04 23:10:49 1232
翻译 ITU ITU-T
http://en.wikipedia.org/wiki/ITU-T International Telecommunication Union分三部分: Radiocommunication (ITU-R)Standardization (ITU-T) ,前身是CCITTDevelopment (ITU-D)Key standards published by
2012-09-04 21:12:58 741
翻译 LAN
http://en.wikipedia.org/wiki/Local_area_networkARCNET, Token Ring and other technology standards 以前被使用过。基于双绞线的Ethernet 和WIFI是两个当前应用最广的技术。TCP/IP protocol已经几乎替代了IPX,AppleTalk,NBF
2012-09-04 16:08:59 566
原创 打patch
diff -up oldfile newfile > oldfile.patchpatch -Np1 oldfile.patch1、patch文件中首部为:--- 原始文件名+++ 新文件名2、patch执行位置:个人认为在待修改文件的目录下比较好,用-p来控制深度。3、注意-p 深度,表明patch文件中,文件名去除的“深度”。
2012-09-04 15:43:19 846
转载 硬链接 软链接
http://www.cnblogs.com/stli/archive/2010/11/10/1873212.html硬连接有两个限制:不能跨越文件系统和不允许普通用户对目录作硬连接。软链接,新建一个文件。
2012-09-04 13:31:28 704
转载 Base64编码
http://zh.wikipedia.org/wiki/Base64大小写字母各26个,加上10个数字,和加号「+」,斜杠「/」,一共64个字符,等号「=」用来作为后缀用途。每76个字符,还需要加上一个回车换行。字符串可能不能被3整除,补一个字节的,后面添一个=号;补两个字节的,后面添两个等号(补的0不要,替换为等号)。
2012-09-03 13:35:36 489
原创 单向散列函数,HASH算法
http://en.wikipedia.org/wiki/Comparison_of_cryptographic_hash_functionsMD2 MD4 Message-Digest Algorithm,影响了MD5,SHA-1等算法;MD5 已被攻破,美国已经不推荐使用。MD6 在改进中,因速度问题没有被SHA-3采用。SHA-0 被淘汰SHA
2012-09-03 11:26:10 1378
移动IP_chinapub
2011-06-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人