2011-03-01

Experiment with javascript timers

Javascript timers just don't work as you expected. If you can read Chinese, you can check out this article on how javascript engines are implemented on browsers. The two functions setTimeout and setInterval just work fine normally. I experiment with several abnormal situation to see how it works in abnormal situations. I experiment on MacOSX 10.6.4 and Firefox 3.6.14.

1) Close my computer without closing the browser. When I open my computer again, if the timer should have been triggered during the period that my computer is closed, the timer will be immediately fired. If you use setInterval, the next fire will be t (the interval you set) after this fire, and so on.

2) Tune the clock forwards. This will cause exactly the same situation as previous.

3) Tune the clock backwards. This will cause the most problem in my opinion. If you tune t_i backwards, your next fire will be in (t_i + t_left) where t_left means the time left to fire if you didn't tune the clock.

4) Change the local time zone. Nothing is changed except an additional time zone stamp if you print the Date() object in javascript.

To sum up, javascript timers are totally based local clock, they are not real clocks, but just comparing to the local clock periodically...

2009-10-08

Native Client

今天听了Brad Chen的讲座,关于Google的Native Client的。CSE讲座了好多天,终于有和CS相关的了,而且还是system相关的,赞一个。

据我的理解,Native Client大概就是让浏览器能够执行更加底层的code,比如X86,比Javescript这种要快得多,当然它又得在安全性上得到平衡,所以需要对汇编语言进行一系列处理,保证其安全。听起来挺简单的一个idea,它的big picture是google对浏览器乃至操作系统的重新定义,为了满足人们日益增长的用户体验需求。。。

浏览器真是个很灵的东东啊,其思想“运行网络上传来的代码”挺值得深思的。老板PhD的时候搞的东西叫active network,大概是让routers运行传来的代码,但因为安全问题,貌似后来搞的人挺少的了。看来这个安全的问题,真的很难界定。

昨天seminar听Roxana讲她最近的工作,大概是用DHT来处理security/privacy相关问题,具体的没有听得特别明白,感觉是利用DHT这种分布式系统,谁也别想知道全部东西,还有DHT的churn来实现的。。。想来想去不知道这种方法是否靠谱啊。。。不过既然都实现了,应该也是一定程度上靠谱的吧。。。

2009-09-29

如何在看paper时get focused

一直为看paper不能集中精力而犯愁,归根结蒂是精神状态不够紧张,没有感觉到非看完过不下去。明天就上课了,于是今天晚上不得不看完。最orz的是,这篇paper居然是在和蒹葭同学聊天的时候看完的,而且这样效率奇高,因为我得承受今天晚上看完和快点和同学聊天的双重压力。于是聊两句看两段,一会儿就看完了。。。orz