惊动大神的JavaScript:在Web上运行Linux

开发 前端
一个叫Fabrice Bellard的程序员写了一段Javascript在Web浏览器中启动Linux(原网页,我把这个网页iframe在了下面),目前,你只能使用Firefox 4和Chrome 11运行这个Linux。

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

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

随后,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技术很烂的五个表现
责任编辑:陈贻新 来源: 酷壳
相关推荐

2011-03-25 11:21:36

NagiosLinux

2020-06-11 14:33:10

MacBookLinux软件

2010-11-17 09:29:31

linux Fedora 13Ubuntu 10.0

2016-02-16 09:36:37

CrossOverLinuxWindows

2022-06-30 13:54:16

BottlesLinuxWindows

2020-06-01 16:25:43

WindowsLinux命令

2021-11-23 09:20:25

Wine 6.22LinuxWindows

2013-07-02 11:34:46

SUSELinuxWindows Azu

2013-07-02 10:52:42

SUSELinuxWindows Azu

2022-01-18 17:57:21

PodmanLinux容器

2009-06-27 21:35:50

Linux服务器

2015-10-14 10:02:33

ClojureScri Android

2023-01-26 11:56:31

Kubernete虚拟机k3s

2011-02-16 09:06:51

SUSE LinuxIBMWatson

2021-03-09 11:09:10

LinuxWindows应用程序

2023-04-12 15:37:31

Linux系统CPU

2020-02-05 08:00:00

LinuxMacOSWindows

2022-06-23 09:55:56

WineZGUILinux 桌面Windows 应用

2019-10-09 16:50:48

SSHLinux远程系统

2021-12-14 16:15:47

LinuxNginxWeb
点赞
收藏

51CTO技术栈公众号