raspberry pi wn725n driver

raspberry pi wn725n driver http://www.raspberrypi.org/phpBB3/viewtopic.php?t=55779 http://lukin.cn/p/Raspberry_Pi_TP-LINK_WN725N_V2.html wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20130209.tar.gz for 3.6.11+ #538 and #541 use 8188eu-20130830.tar.gz for 3.6.11+ #524, #528 or #532 use 8188eu-20130815.tar.gz for 3.6.11+ #371 up to #520 use 8188eu-20130209.tar.gz sudo install -p -m 644 8188eu.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless sudo depmod -a sudo modprobe 8188eu

2013-11-30 · 1 min · 45 words · -

socket, 套接字, 套接口

socket, 套接字, 套接口 应用层通过传输层进行数据通信时,TCP 和 UDP 会遇到同时为多个应用程序进程提供并发服务的问题。多个 TCP 连接或多个应用程序进程可能需要通过同一个 TCP 协议端口传输数据。为了区别不同的应用程序进程和连接,许多计算机操作系统为应用程序与 TCP/IP 协议交互提供了称为 socket (Socket) 的接口,区分不同应用程序进程间的网络通信和连接。 生成 socket ,主要有3个参数: 通信的目的 IP 地址、使用的传输层协议(TCP或UDP)和使用的端口号。Socket原意是"插座"。通过将这3个参数结合起来,与一个"插座"Socket绑定,应用层就可以和传输 层通过 socket 接口,区分来自不同应用程序进程或网络连接的通信,实现数据传输的并发服务。 Socket可以看成在两个程序进行通讯连接中的一个端点,一个程序将一段信息写入Socket中,该Socket将这段信息发送给另外一个Socket中,使这段信息能传送到其他程序中。 Host A上的程序A将一段信息写入Socket中,Socket的内容被Host A的网络管理软件访问,并将这段信息通过Host A的网络接口卡发送到Host B,Host B的网络接口卡接收到这段信息后,传送给Host B的网络管理软件,网络管理软件将这段信息保存在Host B的Socket中,然后程序B才能在Socket中阅读这段信息。 要通过互联网进行通信,至少需要一对 socket ,一个运行于客户机端,称之为ClientSocket,另一个运行于服务器端,称之为serverSocket。 根据连接启动的方式以及本地 socket 要连接的目标, socket 之间的连接过程可以分为三个步骤: 服务器监听,客户端请求,连接确认。 服务器监听: 是服务器端 socket 并不定位具体的客户端 socket ,而是处于等待连接的状态,实时监控网络状态。 客户端请求: 是指由客户端的 socket 提出连接请求,要连接的目标是服务器端的 socket 。为此,客户端的 socket 必须首先描述它要连接的服务器的 socket ,指出服务器端 socket 的地址和端口号,然后就向服务器端 socket 提出连接请求。 连 接确认: 是指当服务器端 socket 监听到或者说接收到客户端 socket 的连接请求,它就响应客户端 socket 的请求,建立一个新的线程,把服务器端 socket 的描述发给客 户端,一旦客户端确认了此描述,连接就建立好了。而服务器端 socket 继续处于监听状态,继续接收其他客户端 socket 的连接请求。 ...

2013-11-17 · 2 min · 260 words · -

亚马逊土耳其机器人

亚马逊土耳其机器人 亚马逊土耳其机器人 (Amazon Mechanical Turk) 是一个Web服务应用程序接口 (API) ,开发商通过它可以将人的智能整合到远程过程调用 (RPC) 。亚马逊土耳其机器人利用人的网络来执行不适合计算机执行的任务。亚马逊调用那些计算机很难完成但"人工的人工智能"却能很容易执行的任务。执行人工智能任务 (HIT) 的人可能会被要求写产品描述,对移动语音搜索查询作出回应或选择某一主题的最佳照片等等。 下面是它的工作过程: 当用户提出一个要求,应用程序就会将这一请求发送到执行任务的人。人就会对此作出应答,然后服务器将回应传给请求者。土耳其工人的工资是按成功完成人工智能任务来计算的。亚马逊 (Amazon) 通过收取成功完成请求者人工智能任务的百分之十的价格来获利。 土耳其机器人 (Mechanical Turk) 这个名字是从18世纪的一个国际象棋游戏机器人得来的,这个机器人在欧洲参观并与名人比赛下象棋,其中包括拿破仑和本•富兰克林。每场演出之前,观众都可以检查土耳其机器人,以查看它的许多职能齿轮和杠杆。然而,和所有神奇的事物一样,土耳其机器人只是一种幻想。其实在机器人中有一个真人躲在一个秘密隔间中,是他在操纵机器人和玩象棋。 亚马逊 (Amazon) 选择土耳其机器人 (Mechanical Turk) 这个名字来命名他们的网络服务,是因为人类的智慧隐藏在最终用户,这样服务看起来就像是自动进行的。

2013-11-17 · 1 min · 26 words · -

iptables basic

iptables basic iptables 是 Linux 内核集成的 IP 信息包过滤系统。该系统用于在 Linux 系统上控制 IP 数据包过滤和防火墙配置 iptables 操作的是 2.4 以上内核的 netfilter。所以需要 linux 的内核在 2.4 以上。其功能与安全性远远比其前辈 ipfwadm, ipchains 强大,iptables大致是工作在OSI七层的二、三、四层,其前辈ipchains不能单独实现对tcp/udp port以及对mac地址的的定义与操作 iptables-nft iptables vs. iptables-nft https://developers.redhat.com/blog/2020/08/18/iptables-the-two-variants-and-their-relationship-with-nftables#the_iptables_rules_appear_in_the_nftables_rule_listing iptables 包含4个表,5个链 其中表是按照对数据包的操作区分的,链是按照不同的Hook点来区分的,表和链实际上是netfilter的两个维度. 4个表: filter, nat, mangle, raw,默认表是 filter (没有指定表 ( -t ) 的时候就是filter表) 。 表的处理优先级: raw>mangle>nat>filter 4 个表 filter: 一般的过滤功能, 这是默认的表,包含了内建的链 INPUT (处理进入的包)、FORWARD (处理通过的包) 和OUTPUT (处理本地生成的包) 。 nat: 用于nat功能 (端口映射,地址映射等),对应的链: PREROUTING (修改到来的包)、OUTPUT (修改路由之前本地的包) 、POSTROUTING (修改准备出去的包) ,centos6没有input链,centos7 有 input 链。 mangle: 用于对特定数据包的修改, 对应的链: PREROUTING (修改路由之前进入的包) ,input, OUTPUT (修改路由 IPTABLES 之前本地的包), forward, postrouting raw: 优先级最高,设置raw时一般是为了不再让iptables做数据包的链接跟踪处理,提高性能 5 个链: PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING PREROUTING: 数据包进入路由表之前 INPUT: 通过路由表后目的地为本机 FORWARD: 通过路由表后, 目的地不为本机 OUTPUT: 由本机产生, 向外转发 POSTROUTIONG: 发送到网卡接口之前 iptables 规则的语法 iptables [-t table] COMMAND chain CRETIRIA -j ACTION -t table : 3个filter nat mangle COMMAND: 定义如何对规则进行管理 chain: 指定你接下来的规则到底是在哪个链上操作的,当定义策略的时候,是可以省略的 CRETIRIA:指定匹配标准 -j ACTION :指定如何进行处理 iptables [-t table] COMMAND chain CRETIRIA -j ACTION iptables [-t table] -[AD] chain rule-specification [options] iptables [-t table] -I chain [rulenum] rule-specification [options] iptables [-t table] -R chain rulenum rule-specification [options] iptables [-t table] -D chain rulenum [options] iptables [-t table] -[LFZ] [chain] [options] # 创建新的链 iptables [-t table] -N chain iptables [-t table] -X [chain] iptables [-t table] -P chain target [options] iptables [-t table] -E old-chain-name new-chain-name # 创建链 iptables -t mangle -N chain0 指定链 iptables -t filter -L FORWARD nf_conntrack iptalbes 会使用 nf_conntrack 模块跟踪连接,而这个连接跟踪的数量是有最大值的,当跟踪的连接超过这个最大值,就会导致连接失败。 通过命令查看 ...

2013-11-10 · 7 min · 1412 words · -

vmpk

vmpk Virtual MIDI Piano Keyboard is a MIDI events generator and receiver. It doesn’t produce any sound by itself, but can be used to drive a MIDI synthesizer (either hardware or software, internal or external). You can use the computer’s keyboard to play MIDI notes, and also the mouse. You can use the Virtual MIDI Piano Keyboard to display the played MIDI notes from another instrument or MIDI file player. To do so, connect the other MIDI port to the input port of VMPK. (http://vmpk.sourceforge.net/) ...

2013-11-09 · 1 min · 99 words · -

form表单target的用法

form表单target的用法 偶然有一机会发现form表单的target的用法,可以实现当前页表单提交而不进行跳转刷新。代码如下,首页在页面里准备一form表单和一iframe Java代码 <img alt="收藏代码" src="http://vsp.iteye.com/images/icon_star.png" /> <form action="提交的action" method="post" target="theID"> ..................... </form> 提交到action后,action返回一串javascript语句 Java代码 <img alt="收藏代码" src="http://vsp.iteye.com/images/icon_star.png" /> String script = "<script>alert('ok!');</script>"; response.getOutputStream().write(script.getBytes("utf-8")); alert(‘ok’)将在当前页执行。原理是form提交后的结果在target指定的iframe里执行 而iframe将其隐藏。这样提交后的效果就和无刷新的效果一样。 http://vsp.iteye.com/blog/1570466

2013-11-06 · 1 min · 27 words · -

Add ISO image to apt sources.list

Add ISO image to apt sources.list http://linuxconfig.org/add-iso-image-to-apt-sourceslist Here is a way how to include Debian/Ubuntu ISO image into your /etc/apt/sources.list file. This kind of hack can prove handy in terms of reducing package download during the installation or if you do not have CD/DVD drive available ( or is broken ) on your system. Let’s assume that we have a Debian ISO image downloaded at the location: /mnt/storage/iSO/debian-i386-DVD-1.iso. As a first step we need to create a mount point to where this ISO image will be mounted to: ...

2013-11-01 · 1 min · 170 words · -

结构化,半结构化和非结构化数据

结构化,半结构化和非结构化数据 相对于结构化数据(即行数据,存储在数据库里,可以用二维表结构来逻辑表达实现的数据)而言,不方便用数据库二维逻辑表来表现的数据即称为非结构化数据,包括所有格式的办公文档、文本、图片、XML、HTML、各类报表、图像和音频/视频信息等等。 字段可根据需要扩充,即字段数目不定,可称为半结构化数据,例如Exchange存储的数据。 非结构化数据库 在信息社会,信息可以划分为两大类。一类信息能够用数据或统一的结构加以表示,我们称之为结构化数据,如数字、符号;而另一类信息无法用数字或统一的结构表示,如文本、图像、声音、网页等,我们称之为非结构化数据。结构化数据属于非结构化数据,是非结构化数据的特例。 随着网络技术的发展,特别是Internet和Intranet技术的飞快发展,使得非结构化数据的数量日趋增大。这时,主要用于管理结构化数据的关系 数据库的局限性暴露地越来越明显。因而,数据库技术相应地进入了"后关系数据库时代",发展进入基于网络应用的非结构化数据库时代。所谓非结构化数据库, 是指数据库的变长纪录由若干不可重复和可重复的字段组成,而每个字段又可由若干不可重复和可重复的子字段组成。简单地说,非结构化数据库就是字段可变的数 据库。 http://blog.csdn.net/wenqin2006/article/details/2368871

2013-10-26 · 1 min · 10 words · -

chrome 扩展/插件

chrome 扩展/插件 SwitchyOmega

2013-10-23 · 1 min · 3 words · -

外汇市场的开市时间

外汇市场的开市时间 外汇市场的开市时间: 伦敦(London) – 美东时间 早上3点到中午12点(夏令时的北京时间下午15点到凌晨24点); 约占总外汇交易量的35% 纽约(New York) – 美东时间早上8点到下午17点(夏令时的北京时间晚上20点到翌日凌晨5点); 约占外汇总交易量的20% 悉尼(Sydney) – 美东时间下午17点到翌日凌晨2点 (夏令时的北京时间早上5点到下午14点); 约占外汇总交易量的4% 东京(Tokyo) – 美东时间晚上19点到翌日凌晨4点 (夏令时的北京时间早上7点到下午16点); 约占外汇总交易量的6%

2013-10-07 · 1 min · 22 words · -

fuser 命令用法详解

fuser 命令用法详解 http://www.ha97.com/category/linux" rel=“category tag http://www.ha97.com/tag/linux 查看哪些进程正在访问特定的文件、目录或端口。它也可以配合选项来终止这些进程。 语法 # fuser [ -c | -d | -f ] [ -k ] [ -u ] [ -x ] [ -V ]文件 … # 查看正在使用 TCP 端口 2222 的进程 fuser 2222/tcp # 终止(kill)正在使用 TCP 端口 2222 的进程 # || true 可以忽略失败,确保整个命令的退出码是 0(成功),防止脚本中断。 sudo fuser -k 2222/tcp || true 描述 此 fuser 命令列出了本地进程的进程号,那些本地进程使用File 参数指定的本地或远程文件。对于阻塞特别设备,此命令列出了使用该设备上任何文件的进程。 每个进程号后面都跟随一个字母,该字母指示进程如何使用文件。 c 将此文件作为当前目录使用。 e 将此文件作为程序的可执行对象使用。 r 将此文件作为根目录使用。 s 将此文件作为共享库 (或其它可装载对象) 使用。 ...

2013-10-06 · 1 min · 156 words · -

raspberry pi eth0 x60s wlan0 squid

raspberry pi eth0 x60s wlan0 squid raspberry pi eth0:192.168.0.59, mask 255.255.255.0 -> x60s eth0:192.168.0.1, mask 255.255.255.0, gateway:192.168.1.1, dns:192.168.1.1 -> x60s wlan0:192.168.1.119 mask:255.255.255.0 gateway:192.168.1.1 dns:192.168.1.1

2013-09-27 · 1 min · 24 words · -

程序计数器, The Program Counter, PC

程序计数器, The Program Counter, PC program counter (PC) 一般也被叫做 instruction pointer (IP), 在intel x86 cpu里有时候也被叫做 instruction address register (IAR), instruction counter, 或者是 instruction sequencer 的一部分, 程序计数器 程序计数器是用于存放执行指令的地方。 为了保证程序(在操作系统中理解为进程)能够连续地执行下去,CPU必须具有某些手段来确定下一条指令的地址。而程序计数器正是起到这种作用,所以通常又称为指令计数器。 在程序开始执行前,必须将它的起始地址,即程序的一条指令所在的内存单元地址送入PC,因此程序计数器 (PC) 的内容即是从内存提取的第一条指令的地址。当执行指令时,CPU将自动修改PC的内容,即每执行一条指令PC增加一个量,这个量等于指令所含的字节数,以便使其保持的总是将要执行的下一条指令的地址。由于大多数指令都是按顺序来执行的,所以修改的过程通常只是简单的对PC加1。 当程序转移时,转移指令执行的最终结果就是要改变PC的值,此PC值就是转去的地址,以此实现转移。有些机器中也称PC为指令指针IP (Instruction Pointer) 。 程序计数器 (Program Counter Register) 是一块较小的内存空间,它的作用可以看做是当前线程所执行的字节码的行号指示器。在虚拟机的概念模型里 (仅是概念模型,各种虚拟机可能会通过一些更高效的方式去实现) ,字节码解释器工作时就是通过改变这个计数器的值来选取下一条需要执行的字节码指令,分支、循环、跳转、异常处理、线程恢复等基础功能都需要依赖这个计数器来完成。 由于Java虚拟机的多线程是通过线程轮流切换并分配处理器执行时间的方式来实现的,在任何一个确定的时刻,一个处理器 (对于多核处理器来说是一个内核) 只会执行一条线程中的指令。因此,为了线程切换后能恢复到正确的执行位置,每条线程都需要有一个独立的程序计数器,各条线程之间的计数器互不影响,独立存储,我们称这类内存区域为"线程私有"的内存 如果线程正在执行的是一个Java方法,这个计数器记录的是正在执行的虚拟机字节码指令的地址;如果正在执行的是Natvie方法,这个计数器值则为空 (Undefined) 。此内存区域是唯一一个在Java虚拟机规范中没有规定任何OutOfMemoryError情况的区域。 以上描述截取自: 《深入理解Java虚拟机:JVM高级特性与最佳实践》 作者: 周志明 Each thread of a running program has its own pc register, or program counter, which is created when the thread is started. The pc register is one word in size, so it can hold both a native pointer and a returnValue. As a thread executes a Java method, the pc register contains the address of the current instruction being executed by the thread. An “address” can be a native pointer or an offset from the beginning of a method’s bytecodes. If a thread is executing a native method, the value of the pc register is undefined. ...

2013-09-27 · 1 min · 170 words · -

How to configure Office applications to run under a specific user account

How to configure Office applications to run under a specific user account This article was previously published under Q288367 SUMMARY We do not recommend or support automation to a Microsoft Office application from an unattended user account. For additional information on why Microsoft does not recommend automation under this context, click the following article number to view the article in the Microsoft Knowledge Base:257757 Considerations for server-side automation of Office If there is no choice but to automate Office from an unattended user account, the following steps can be used to configure the computer to run the Office application as a specific user, giving the application a fixed identity when it is started for Automation. MORE INFORMATION Caution Automation of any Office application from an unattended, non-interactive user account is risky and unstable. A single error in code or configuration can result in a dialog box that can cause the client process to stop responding (hang), that can corrupt data, or that can even crash the calling process (which could bring down your Web server if the client is ASP). Warning Office was not designed, and is not safe, for unattended execution on a server. Developers who use Office in this manner do so at their own risk. Regardless, it may be absolutely required to use Office in this manner. In these cases, special configuration must be done to avoid errors on Office startup. The steps in this article demonstrate how to configure Office to run as a specific user account when it is started for Automation. When you automate under a specific user account, you should be aware of the following problems: Any process that creates an Automation instance of the configured Office application creates the instance under the specific user account, allowing it to run with that user's security credentials. Setting the Distributed Componenet Object Model (DCOM) settings to run as a specific user is global to the system. This setting affects all users and programs that automate the Office application on the system. Terminal Server clients may not be able to use Office appropriately. You should not use this setting and the steps in this article on an application Terminal Server. Component Object Model (COM) creates a unique WinStation for the new instance of the Office application. Any dialog boxes or warnings that may display do not appear on the interactive desktop. If you set the Visible flag for an application, the interactive user will not see that application. For more information about COM and WinStations, see the "References" section. When COM loads a server to run as a specific user account, the registry hive for that user is not loaded. Because the hive is not loaded for that user, the system .DEFAULT hive is used. Because Office has not been run under an account with this hive, you may receive dialog boxes that prompt you for input or the Office CD-ROMs to complete installation. The dialog boxes are not visible on the interactive desktop, so the application appears to stop responding (hang). The dialog boxes may time out and allow the process to continue, but after a noticeable delay in running the program. To work around this situation, install an NT service that runs under the same user account that is set for the DCOM setting. The NT Service Control Manager (SCM) loads the hive for that user when the service starts. Because the changes in DCOM are global, configuring Office in this manner can have negative side effects for other clients on the system that use Office. It is possible that another client application, or Terminal Server clients, will not be able to use the Office application after the settings are made. Consider carefully what impact this has to your server before you make any changes to the DCOM configuration settings. If the problems listed here are too great for your design, or cause other unidentified problems, it is possible to configure Office differently and still allow it to start from an unattended process or service. For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:288366 How To Configure Office Applications to Run Under the Interactive User Account 288368 How To Configure Office Applications for Automation from a COM+/MTS Package Configuring Office as a Specific User To set up an Office Automation server under a specific user account, follow these steps: Log on to the computer as the Administrator and create a new user account that will automate Office. In our example, this account is named OfficeAutomationUser. Create a password for this user account, and select Never expire so that the password does not have to be changed. Add the OfficeAutomationUser account to the Administrators group. Log in to the computer as OfficeAutomationUser and install (or reinstall) Office using a complete install. For system robustness, it is recommended that you copy the contents of the Office CD-ROM to a local drive and install Office from this location. Start the Office application that you intend to automate. This forces the application to register itself. After the application is running, press ALT+F11 to load the Microsoft Visual Basic for Applications (VBA) editor. This forces VBA to initialize itself. Close the applications, including VBA. Click Start, click Run, and then type <kbd>DCOMCNFG</kbd>. Select the application that you want to automate. The application names are listed below:Microsoft Access 97/2002 - Microsoft Access Database Microsoft Access 2003 - Microsoft Office Access Application Microsoft Excel 97/2000/2002/2003 - Microsoft Excel Application Microsoft Word 97 - Microsoft Word Basic Microsoft Word 2000/2002/2003 - Microsoft Word Document Click Properties to open the property dialog box for this application. ...

2013-09-23 · 7 min · 1344 words · -

虚拟机栈(Virtual Machine Stack),栈帧(Stack Frame)

虚拟机栈(Virtual Machine Stack),栈帧(Stack Frame) 栈帧(Stack Frame) 栈帧(Stack Frame)是用于支持虚拟机进行方法调用和方法执行的数据结构,它是虚拟机运行时数据区的虚拟机栈 (Virtual Machine Stack)的栈元素。栈帧存储了方法的局部变量表,操作数栈,动态连接和方法返回地址等信息。第一个方法从调用开始到执行完成,就对应着一个栈帧在虚拟机栈中从入栈到出栈的过程。 每一个栈帧都包括了局部变量表,操作数栈,动态连接,方法返回地址和一些额外的附加信息。在编译代码的时候,栈帧中需要多大的局部变量表,多深的操作数栈都已经完全确定了,并且写入到了方法表的Code属性中,因此一个栈帧需要分配多少内存,不会受到程序运行期变量数据的影响,而仅仅取决于具体虚拟机的实现。 一个线程中的方法调用链可能会很长,很多方法都同时处理执行状态。对于执行引擎来讲,活动线程中,只有虚拟机栈顶的栈帧才是有效的,称为当前栈帧(Current Stack Frame),这个栈帧所关联的方法称为当前方法(Current Method)。执行引用所运行的所有字节码指令都只针对当前栈帧进行操作。 局部变量表 局部变量表是一组变量值存储空间,用于存放方法参数和方法内部定义的局部变量。在Java程序编译为Class文件时,就在方法表的Code属性的max_locals数据项中确定了该方法需要分配的最大局部变量表的容量。 在方法执行时,虚拟机是使用局部变量表完成参数变量列表的传递过程,如果是实例方法,那么局部变量表中的每0位索引的Slot默认是用于传递方法所属对象实例的引用,在方法中可以通过关键字"this"来访问这个隐含的参数,其余参数则按照参数列表的顺序来排列,占用从1开始的局部变量Slot,参数表分配完毕后,再根据方法体内部定义的变量顺序和作用域来分配其余的Slot。局部变量表中的Slot是可重用的,方法体中定义的变量,其作用域并不一定会覆盖整个方法,如果当前字节码PC计算器的值已经超出了某个变量的作用域,那么这个变量对应的Slot就可以交给其它变量使用。 局部变量不像前面介绍的类变量那样存在"准备阶段"。类变量有两次赋初始值的过程,一次在准备阶段,赋予系统初始值;另外一次在初始化阶段,赋予程序员定义的值。因此即使在初始化阶段程序员没有为类变量赋值也没有关系,类变量仍然具有一个确定的初始值。但局部变量就不一样了,如果一个局部变量定义了但没有赋初始值是不能使用的。 操作数栈 Java虚拟机的解释执行引擎被称为"基于栈的执行引擎",其中所指的栈就是指-操作数栈。 和局部变量区一样,操作数栈也是被组织成一个以字长为单位的数组。但是和前者不同的是,它不是通过索引来访问,而是通过标准的栈操作—压栈和出栈—来访问的。比如,如果某个指令把一个值压入到操作数栈中,稍后另一个指令就可以弹出这个值来使用。 虚拟机在操作数栈中存储数据的方式和在局部变量区中是一样的: 如int、long、float、double、reference和returnType的存储。对于byte、short以及char类型的值在压入到操作数栈之前,也会被转换为int。 虚拟机把操作数栈作为它的工作区——大多数指令都要从这里弹出数据,执行运算,然后把结果压回操作数栈。比如,iadd 指令就要从操作数栈中弹出两个整数,执行加法运算,其结果又压回到操作数栈中,看看下面的示例,它演示了虚拟机是如何把两个int类型的局部变量相加,再把结果保存到第三个局部变量的: begin iload_0 // push the int in local variable 0 onto the stack iload_1 // push the int in local variable 1 onto the stack iadd // pop two ints, add them, push result istore_2 // pop int, store into local variable 2 end 在这个字节码序列里,前两个指令 iload_0和iload_1将存储在局部变量中索引为0和1的整数压入操作数栈中,其后iadd指令从操作数栈中弹出那两个整数相加,再将结果压入操作数栈。第四条指令istore_2则从操作数栈中弹出结果,并把它存储到局部变量区索引为2的位置。 操作数栈也常被称为操作栈,它是一个后入先出栈(Last in First out,LIFO)。同局部变量表一样,操作数栈的最大深度也是编译的时候被写入到方法表的Code属性的max_stacks数据项中。操作数栈的每一个元素可以是任意Java数据类型,包括long和double。32位数据类型所占的栈容量为1,64位数据类型所占的栈容量为2。栈容量的单位为"字宽",对于32位虚拟机来说,一个"字宽"占4个字节,对于64位虚拟机来说,一个"字宽"占8个字节。 ...

2013-09-16 · 1 min · 98 words · -

偏向锁(Biased Locking)

偏向锁(Biased Locking) Java偏向锁(Biased Locking) 是Java6引入的一项多线程优化。它通过消除资源无竞争情况下的同步原语,进一步提高了程序的运行性能。 轻量级锁也是一种多线程优化,它与偏向锁的区别在于,轻量级锁是通过CAS来避免进入开销较大的互斥操作,而偏向锁是在无竞争场景下完全消除同步,连CAS也不执行 (CAS本身仍旧是一种操作系统同步原语,始终要在JVM与OS之间来回,有一定的开销) 。 所谓的无竞争场景,举个例子,就是单线程访问带同步的资源或方法。 偏向锁实现原理 偏向锁,顾名思义,它会偏向于第一个访问锁的线程,如果在接下来的运行过程中,该锁没有被其他的线程访问,则持有偏向锁的线程将永远不需要触发同步。 如果在运行过程中,遇到了其他线程抢占锁,则持有偏向锁的线程会被挂起,JVM会尝试消除它身上的偏向锁,将锁恢复到标准的轻量级锁。(偏向锁只能在单线程下起作用) 偏向模式和非偏向模式,在下面的mark word表中,主要体现在thread ID字段是否为空。 挂起持有偏向锁的线程,这步操作类似GC的pause,但不同之处是,它只挂起持有偏向锁的线程 (非当前线程) 。 在抢占模式的橙色区域说明中有提到,指向当前堆栈中最近的一个lock record (在轻量级锁原理一文有讲到,lock record是进入锁前会在stack上创建的一份内存空间) 。 这里提到的最近的一个lock record,其实就是当前锁所在的stack frame上分配的lock record。 整个步骤是从偏向锁恢复到轻量级锁的过程。 偏向锁也会带来额外开销 在JDK6中,偏向锁是默认启用的。它提高了单线程访问同步资源的性能。 但试想一下,如果你的同步资源或代码一直都是多线程访问的,那么消除偏向锁这一步骤对你来说就是多余的。事实上,消除偏向锁的开销还是蛮大的。 所以在你非常熟悉自己的代码前提下,大可禁用偏向锁 -XX:-UseBiasedLocking 。 http://blog.csdn.net/hsuxu/article/details/9472381 http://www.cnblogs.com/paddix/p/5405678.html

2013-09-13 · 1 min · 36 words · -

进入safepoint时如何让Java线程全部阻塞

进入safepoint时如何让Java线程全部阻塞 http://blog.csdn.net/iter_zc/article/details/41892567 在这篇聊聊JVM (六) 理解JVM的safepoint 中说了safepoint的基本概念,VM thread在进行GC前,必须要让所有的Java线程阻塞,从而stop the world,开始标记。JVM采用了主动式阻塞的方式,Java线程不是随时都可以进入阻塞,需要运行到特定的点,叫safepoint,在这些点的位置Java线程可以被全部阻塞,整个堆的状态是一个暂时稳定的状态,OopMap指出了这个时刻,寄存器和栈内存的哪些具体的地址是引用,从而可以快速找到GC roots来进行对象的标记操作。 那么当Java线程运行到safepoint的时候,JVM如何让Java线程挂起呢?这是一个复杂的操作。很多文章里面说了JIT编译模式下,编译器会把很多safepoint检查的操作插入到编译偶的指令中,比如下面的指令来自内存篇: JVM内存回收理论与实现 0x01b6d627: call 0x01b2b210 ; OopMap{[60]=Oop off=460} ;_invokeinterface size ; - Client1::main@113 (line 23) ; {virtual_call} 0x01b6d62c: nop ; OopMap{[60]=Oop off=461} ;_if_icmplt ; - Client1::main@118 (line 23) 0x01b6d62d: test %eax,0x160100 ; {poll} 0x01b6d633: mov 0x50(%esp),%esi 0x01b6d637: cmp %eax,%esi test %eax,0x160100 就是一个safepoint polling page操作。当JVM要停止所有的Java线程时会把一个特定内存页设置为不可读,那么当Java线程读到这个位置的时候就会被挂起 这个回答虽然是没有问题,但是有些点到为止的感觉,有些意犹未尽,我又深挖了一些资料,很多资料连着一起看才能说明问题,下面再深入说说到底JVM是如何让Java线程全部 阻塞的。 Points on Safepoints 这篇文章说明了一些问题。首先是关于一些safepoint的观点 All commercial GCs use safepoints. The GC reigns in all threads at safepoints. This is when it has exact knowledge of things touched by the threads. They can also be used for non-GC activity like optimization. A thread at a safepoint is not necessarily idle but it often is. Safepoint opportunities should be frequent. All threads need to reach a global safepoint typically every dozen or so instructions (for example, at the end of loops). safepoint机制可以stop the world,不仅仅是在GC的时候用,有很多其他地方也会用它来stop the world,阻塞所有Java线程,从而可以安全地进行一些操作。 看一下OpenJDK里面关于safepoint的一些说明 ```java // Begin the process of bringing the system to a safepoint. // Java threads can be in several different states and are // stopped by different mechanisms: // // 1. Running interpreted // The interpeter dispatch table is changed to force it to // check for a safepoint condition between bytecodes. // 2. Running in native code // When returning from the native code, a Java thread must check // the safepoint _state to see if we must block. If the // VM thread sees a Java thread in native, it does // not wait for this thread to block. The order of the memory // writes and reads of both the safepoint state and the Java // threads state is critical. In order to guarantee that the // memory writes are serialized with respect to each other, // the VM thread issues a memory barrier instruction // (on MP systems). In order to avoid the overhead of issuing // a mem barrier for each Java thread making native calls, each Java // thread performs a write to a single memory page after changing // the thread state. The VM thread performs a sequence of // mprotect OS calls which forces all previous writes from all // Java threads to be serialized. This is done in the // os::serialize_thread_states() call. This has proven to be // much more efficient than executing a membar instruction // on every call to native code. // 3. Running compiled Code // Compiled code reads a global (Safepoint Polling) page that // is set to fault if we are trying to get to a safepoint. // 4. Blocked // A thread which is blocked will not be allowed to return from the // block condition until the safepoint operation is complete. // 5. In VM or Transitioning between states // If a Java thread is currently running in the VM or transitioning // between states, the safepointing code will wait for the thread to // block itself when it attempts transitions to a new state. // 可以看到JVM在阻塞全部Java线程之前,Java线程可能处在不同的状态,这篇聊聊JVM (五) 从JVM角度理解线程 说了JVM里面定义的线程所有的状态。 ...

2013-09-13 · 6 min · 1110 words · -

button input, type="button" Which to use?

‘button input, type=“button” Which to use?’ http://web.archive.org/web/20110721191046/http://particletree.com/features/rediscovering-the-button-element/ http://www.peterbe.com/plog/button-tag-in-IE Here’s a page describing the differences (basically you can put html into a <button></button>) And an other page describing why people avoid <button></button> (Hint: IE6) Another IE problem when using <button />: And while we’re talking about IE, it’s got a couple of bugs related to the width of buttons. It’ll mysteriously add extra padding when you’re trying to add styles, meaning you have to add a tiny hack to get things under control. ...

2013-09-08 · 1 min · 83 words · -

OutOfMemoryException Fix

OutOfMemoryException Fix OutOfMemory exceptions are often caused by address space fragmentation in Visual Studio process. For users experiencing excessive OutOfMemory exceptions we provide a tool which overrides Visual Studio’s memory allocation policy to ensure more continuous address space for Common Language Runtime. To use the tool download wrappers.zip file, unpack it and run devenv2005_wrap, devenv2008_wrap and devenv2010_wrap instead of devenv.exe for Visual Studio 2005, 2008 and 2010 correspondingly. In some cases Visual Studio fails to start under wrappers. Check AppInit_DLLs. Rogue DLLs activated from there can interfere with wrappers. Example: wxvault.dll preinstalled with Dell laptops. ...

2013-09-04 · 1 min · 112 words · -

sql 的四舍五入取整问题

sql 的四舍五入取整问题 转自: http://hi.baidu.com/yahuudang/blog/item/4c65ab77f758b01fb151b953.html 经在sql server 2005测试,可以通过 SELECT CAST(‘123.456’ as decimal) 将会得到 123 (小数点后面的将会被省略掉) 。 如果希望得到小数点后面的两位。 则需要把上面的改为 SELECT CAST(‘123.456’ as decimal(38, 2)) ===>123.46 自动四舍五入了! 自己的例子: select CAST(AmountRmb as decimal(38)) as heji,CAST(NotFinFee as decimal(38)) as whx,* from Bill_Tab

2013-08-20 · 1 min · 37 words · -