易截截图软件、单文件、免安装、纯绿色、仅160KB

linux關于likely與unlikely

原来likely和unlikely是用来编译优化的,其实都可以没有。我们知道很多cpu里面有告诉缓存,且有预读机制,likely和unlikely就是增加执行判断语句时的命中率。
如果是if(lilely(a)),说明a条件发生的可能性大,那么a为真的语句在编译成二进制的时候就应该紧跟在前面程序的后面,这样就会被cache预读取进去,增加程序执行速度。 unlikely则是正好相反。
kernel里面的定义:
#ifndef __LINUX_COMPILER_H
#define __LINUX_COMPILER_H
/* Somewhere in the middle of the GCC 2.96 development cycle, we implemented
a mechanism by which the user can annotate likely branch directions and
expect the blocks to be reordered appropriately. Define __builtin_expect
to nothing for earlier compilers. */
#if __GNUC__ == 2 && __GNUC_MINOR__ < 96
#define __builtin_expect(x, expected_value) (x)
#endif
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#endif /* __LINUX_COMPILER_H */
可以看到在2.96以前版本中,gcc并没有实现lilely和unlikely。在gcc以后版本中,__builtin_expect是gcc的内置函数。


相关文档:

linux实验三

实验3 Linux的进程控制
一.实验目的
通过实验掌握Linux中进程控制的基本命令。
二.实验要求
1.练习使用who, w, ps,pstree察看系统用户及进程的信息。
2.练习使用kill命令撤销进程。
3.练习进程前后台的切换。
三、         实验报告要求
1.      ......

Linux的工作队列

1,先看看工作队列和tasklet的区别:
    (1) 定时器和tasklet:
    Tasklets resemble kernel timers in 3 ways.
      1)They are always run at interrupt time,
      2)they always run on the same CPU that schedules the ......

linux局域网通信软件iptux,ipmsg

windows下有非常好用的局域网通信软件:ipmsg(飞鸽传书)。
ipmsg也有linux版本,但是,有bug,更新也慢。
linux下有一个国人开发的iptux,兼容ipmsg协议,跨平台使用,更新也很快,你可以随时提交bug,作者会很快修改。
1. iptux
安装iptux比较容易,下载iptux的二进制包http://iptux.googlecode.com/files/iptux_0.4 ......

Linux下nginx的安装

nginx("engine x")是一个高性能的HTTP和反向代理服务器,是由俄罗斯人Igor Sysoev建立的项目,超轻量级,超快处理能力。
目前使用的nginx版本是0.7.61
nginx的官言网站为:http://nginx.net/
下载地址为:http://sysoev.ru/nginx/nginx-0.7.61.tar.gz
nginx需要pcre的支持,所以我们需要下载pcre
pcre全名为Perl Compa ......

wmware linux 网卡问题

Device eth0 has different MAC address than expected
   前天在弄VMware的时候,在VMware上clone了一个linux,后来在clone的linux(RedHat Enterprise Linux 4)上不能上网了,激活eth0时老弹出 Device eth0 has different MAC address than expected ,我们只要编辑这个文件:/etc/sysconfig/network-scripts/ifcfg- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号