2012年2月29日

vim 分屏

摘要: 分屏启动Vim使用大写的O参数来垂直分屏。vim -On file1 file2 ...使用小写的o参数来水平分屏。vim -on file1 file2 ...注释: n是数字,表示分成几个屏。关闭分屏关闭当前窗口。Ctrl+W c关闭当前窗口,如果只剩最后一个了,则退出Vim。Ctrl+W q分屏上下分割当前打开的文件。Ctrl+W s上下分割,并打开一个新的文件。:sp filename左右分割当前打开的文件。Ctrl+W v左右分割,并打开一个新的文件。:vsp filename移动光标Vi中的光标键是h, j, k, l,要在各个屏间切换,只需要先按一下Ctrl+W把光标移到右边的屏 阅读全文

posted @ 2012-02-29 18:20 Richard.FreeBSD 阅读(126) 评论(0) 推荐(0) 编辑

volatile

摘要: volatile就象大家更熟悉的const一样,volatile是一个类型修饰符(type specifier)。它是被设计用来修饰被不同线程访问和修改的变量。如果没有volatile,基本上会导致这样的结果:要么无法编写多线程程序,要么编译器失去大量优化的机会。简单地说就是防止编译器对代码进行优化.比如如下程序: XBYTE[2]=0x55; XBYTE[2]=0x56; XBYTE[2]=0x57; XBYTE[2]=0x58; 如果对外部硬件上述四条语句分别表示不同的操作,会产生四种不同的动作,那么编译器就不能像对 待纯粹的程序那样对上述四条语句进行优化只认为XBYT... 阅读全文

posted @ 2012-02-29 11:31 Richard.FreeBSD 阅读(283) 评论(0) 推荐(0) 编辑

close(1) 1 to state stdout

摘要: Example 1: Reassign a file descriptor. The following example closes the file descriptor associated with standard output for the current process, re-assigns standard output to a new file descriptor, and closes the original file descriptor to clean up. This example assu... 阅读全文

posted @ 2012-02-29 10:38 Richard.FreeBSD 阅读(216) 评论(0) 推荐(0) 编辑

alarm() function

摘要: alarm(设置信号传送闹钟) 相关函数 signal,sleep表头文件 #include<unistd.h>定义函数 unsigned int alarm(unsigned int seconds);函数说明 alarm()用来设置信号SIGALRM在经过参数seconds指定的秒数后传送给目前的进程。如果参数seconds 为0,则之前设置的闹钟会被取消,并将剩下的时间返回。返回值 返回之前闹钟的剩余秒数,如果之前未设闹钟则返回0。代码#include<unistd.h>#include<signal.h>void handler() {printf( 阅读全文

posted @ 2012-02-29 10:30 Richard.FreeBSD 阅读(269) 评论(0) 推荐(0) 编辑

printf

摘要: printffunction<cstdio> int printf ( const char * format, ... );Print formatted data to stdoutWrites to the standard output (stdout) a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified 阅读全文

posted @ 2012-02-29 10:06 Richard.FreeBSD 阅读(312) 评论(0) 推荐(0) 编辑

Controlling Hardware with ioctls

摘要: Controlling Hardware with ioctlsFrom Issue #117January 2004Dec 31, 2003 ByLisa CorsettiinHardwareOnce you learn the ioctl system call, you'll be able to check the status of the Ethernet link light and other miscellaneous but important facts about hardware.A few years ago, I had a laptop that I u 阅读全文

posted @ 2012-02-29 09:44 Richard.FreeBSD 阅读(208) 评论(0) 推荐(0) 编辑

UNIX nonblocking I/O: O_NONBLOCK vs. FIONBIO

摘要: In every example and discussion I run across in the context of BSD socket programming, it seems that the recommended way to set a file descriptor to nonblocking I/O mode is using the flag to fcntl(), e.g.int flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); I've been doing n 阅读全文

posted @ 2012-02-29 09:33 Richard.FreeBSD 阅读(826) 评论(0) 推荐(0) 编辑

导航