惊动大神的JavaScript:在Web上运行Linux
创始人
2024-07-29 11:50:53
0

一个叫Fabrice Bellard的程序员写了一段Javascript在Web浏览器中启动Linux(原网页,我把这个网页iframe在了下面),目前,你只能使用Firefox 4和Chrome 11运行这个Linux。这不是什么假的模仿Linux的东西,这是实实在在的运行一个Linux。这一举动还引起了很多很牛人的关注,包括Javascript的创建者Brendan Eich。

  1.  
  2. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)                    
  3. TCP established hash table entries: 1024 (order: 0, 4096 bytes)                   
  4. TCP bind hash table entries: 512 (order: -1, 2048 bytes)                          
  5. TCP: Hash tables configured (established 1024 bind 512)                           
  6. TCP reno registered                                                               
  7. checking if image is initramfs...it isn't (bad gzip magic numbers); looks like a  
  8. n initrd                                                                          
  9. Freeing initrd memory: 2048k freed                                                
  10. Total HugeTLB memory allocated, 0                                                 
  11. io scheduler noop registered                                                      
  12. io scheduler anticipatory registered                                              
  13. io scheduler deadline registered                                                  
  14. io scheduler cfq registered (default)                                             
  15. Real Time Clock Driver v1.12ac                                                    
  16. JS clipboard: I/O at 0x03c0                                                       
  17. Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled         
  18. serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450                               
  19. RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize             
  20. loop: loaded (max 8 devices)                                                      
  21. TCP cubic registered                                                              
  22. NET: Registered protocol family 1                                                 
  23. NET: Registered protocol family 17                                                
  24. Using IPI Shortcut mode                                                           
  25. Time: pit clocksource has been installed.                                         
  26. RAMDISK: ext2 filesystem found at block 0                                         
  27. RAMDISK: Loading 2048KiB [1 disk] into ram disk... done.                          
  28. VFS: Mounted root (ext2 filesystem).                                              
  29. Freeing unused kernel memory: 124k freed                                          
  30. W  
  31. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)                    
  32. TCP established hash table entries: 1024 (order: 0, 4096 bytes)                   
  33. TCP bind hash table entries: 512 (order: -1, 2048 bytes)                          
  34. TCP: Hash tables configured (established 1024 bind 512)                           
  35. TCP reno registered                                                               
  36. checking if image is initramfs...it isn't (bad gzip magic numbers); looks like a  
  37. n initrd                                                                          
  38. Freeing initrd memory: 2048k freed                                                
  39. Total HugeTLB memory allocated, 0                                                 
  40. io scheduler noop registered                                                      
  41. io scheduler anticipatory registered                                              
  42. io scheduler deadline registered                                                  
  43. io scheduler cfq registered (default)                                             
  44. Real Time Clock Driver v1.12ac                                                    
  45. JS clipboard: I/O at 0x03c0                                                       
  46. Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled         
  47. serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16450                               
  48. RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize             
  49. loop: loaded (max 8 devices)                                                      
  50. TCP cubic registered                                                              
  51. NET: Registered protocol family 1                                                 
  52. NET: Registered protocol family 17                                                
  53. Using IPI Shortcut mode                                                           
  54. Time: pit clocksource has been installed.                                         
  55. RAMDISK: ext2 filesystem found at block 0                                         
  56. RAMDISK: Loading 2048KiB [1 disk] into ram disk... done.                          
  57. VFS: Mounted root (ext2 filesystem).                                              
  58. Freeing unused kernel memory: 124k freed                                          
  59. Welcome to JS/Linux  

随后,Fabrice Bellard发布了相关的技术说明:http://bellard.org/jslinux/tech.html,从这份文档中我们可以看到:

这个模似器完全由Javascript写成

CPU仿真器使用的是QEMU(接近于原古的486),为了装上Linux,其做了一些改动。

Javascript的终端本来可以使用termlib,但他还是自己写了一个,因为OS的按键和Web浏览器不一样(here)

Linux 使用了2.6.20内核,编译配置在这里,并做了一些小改动。

磁盘用的是Ram Disk,在启动的时候装载。其文件系统由Buildroot 和BusyBox产生。

在Home目录下有一个hello.c的程序,你可以使用TinyCC编译(tcc,参看酷壳的这篇文章)

从这个事我有这些感触,

在Web上运行一个Linux的操作系统不是问题。那么在Web上还有什么不能做的吗?

Linux真是性能很高,在Javascript下运行感觉也不慢啊。

真是Techno-Geek。

原文链接:http://coolshell.cn/articles/4722.html#more-4722

【编辑推荐】

  1. 19个很有用的JavaScript库强烈推荐
  2. 15款超棒的JavaScript开发工具推荐
  3. 从零开始学习jQuery之你必须知道的JavaScript
  4. 高性能WEB开发之如何加载JavaScript
  5. 泄露你的JavaScript技术很烂的五个表现

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...