加入收藏 | 设为首页 | 会员中心 | 我要投稿 佛山站长网 (https://www.0757zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

基于浏览器的Linux

发布时间:2016-10-22 05:51:05 所属栏目:Linux 来源:网络整理
导读:QEMU模拟器项目创始人Fabrice Bellard开发了在JavaScript中运行的模拟器,允许用户在浏览器上(支持Firefox 4和Google Chrome 11)启动Linux。现在,另一位开发者

如何实现的:

作者 Fabrice Bellard 使用 JavaScript 编写了一个简单的 PC 模拟器,包含32位 x86 兼容 CPU、8259 可编程中断控制器、8254 可编程中断计时器

实现 16450 UART 串口设备

用 JavaScript 实现一个终端

编译包含 FPU 模拟的 Linux 内核镜像。

使用 Buildroot 创建文件系统并在启动时载入 RAM。

添加基本工具集 BusyBox,微型 C 编译器 TinyCC,以及迷你编辑器 QEmacs

jslinux 简单分析

jslinux:用JavaScript写出一个PC模拟器,上面运行Linux (The code is written in pure Javascript using Typed Arrays which are available in recent browsers.) 1、主页面 (http://bellard.org/jslinux/) 很简单,主要调用了 如下两个 js 文件。 http://bellard.org/jslinux/term.js http://bellard.org/jslinux/cpux86.js 2、term.js 里也没有发现什么特殊的地方; 3、cpux86.js 使用到一个 load_binary 的函数,查看了一下实现,是通过 XMLHttpRequest 来取如下三个 bin 文件(使用Typed Arrays 操作二进制文件): http://bellard.org/jslinux/vmlinux26.bin http://bellard.org/jslinux/root.bin http://bellard.org/jslinux/linuxstart.bin

根据作者的描述,该模拟器的初衷是了解现在 JavaScript 引擎的工作,尤其是 Firefox 4 的 Jaeger Monkey 和 Chrome 的 V8,这个探索的结果,可以被用来:

通过 Linux 的启动时间反应浏览器的 JavaScript 性能。(作者说目前在 Firefox 4 下比 Chrome 11 要快 2倍,Chrome 12 有 Bug 无法运行)。

实验在用 JavaScript 进行客户端运算时载入 x86 运行库的可能性。

进一步发展从而支持 DOS 游戏的运行。

基于浏览器的Linux 图4  微型 C 编译器 TinyCC          home目录下有个一个hello.c文件,这是将它编译后运行后的结果。有了C编译器,以及QEmacs、vi等文本编译器,我们可以在这个平台上编写C程序。 基于浏览器的Linux 图5  CPU信息基于浏览器的Linux 图6 内存信息

下面是虚拟块设备和本地存储的一些介绍:

This project allows the virtual machine to access a persistent block device. This means a user can format and partition this device inside it's virtual machine. Because this disk is then stored in the HTML5 local storage(存储在HTML5本地存储中), a return to the emulator's web page allows a user to reopen the block device. All data stored on the disk can therefore be read again.

Schematically, the process works in the following way: A block device driver is added to the Linux kernel. This allows a user to operate with a 'device' written in JavaScript. This device is bound to the virtual machine using the same I/O ports as a floppy disk. The device driver itself uses a temporary testing major device node, id 250. Theoretically, it allows dynamic device node allocation, but I have not tested this. On the JavaScript side, a lot of caching occurs because the local storage interface is quite slow. I therefore decided to cache the total 'disk' in memory, because it's about 1M anyway. Writes are cached as well, and are 'flushed' once the driver has transferred a complete sector. For more details, see the source code.

===========================================================================

Javascript PC Emulator - News

Aug 20, 2011:

May 26, 2011:

May 20, 2011:

May 18, 2011:

May 17, 2011:

May 16, 2011:

(编辑:佛山站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读