Caffeinated 6.828：实验 7：最终的 JOS 项目
6.828
![](/data/attachment/album/201901/20/205649f6e69119bzw7wo7r.jpg)


### 简介


对于最后的项目，你有两个选择：


* 继续使用你自己的 JOS 内核并做 [实验 6](https://pdos.csail.mit.edu/6.828/2018/labs/lab6/index.html)，包括实验 6 中的一个挑战问题。（你可以随意地、以任何有趣的方式去扩展实验 6 或者 JOS 的任何部分，当然了，这不是课程规定的。）
* 在一个、二个或三个人组成的团队中，你选择去做一个涉及了你的 JOS 的项目。这个项目必须是涉及到与实验 6 相同或更大的领域（如果你是团队中的一员）。


目标是为了获得乐趣或探索更高级的 O/S 的话题；你不需要做最新的研究。


如果你做了你自己的项目，我们将根据你的工作量有多少、你的设计有多优雅、你的解释有多高明、以及你的解决方案多么有趣或多有创意来为你打分。我们知道时间有限，因此也不期望你能在本学期结束之前重写 Linux。要确保你的目标是合理的；合理地设定一个绝对可以实现的最小目标（即：控制你的实验 6 的规模），如果进展顺利，可以设定一个更大的目标。


如果你做了实验 6，我们将根据你是否通过了测试和挑战练习来为你打分。


### 交付期限



> 
> 11 月 3 日：Piazza 讨论和 1、2、或 3 年级组选择（根据你的最终选择来定）。使用在 Piazza 上的 lab7 标记/目录。在 Piazza 上的文章评论区与其它人计论想法。使用这些文章帮你去找到有类似想法的其它学生一起组建一个小组。课程的教学人员将在 Piazza 上为你的项目想法给出反馈；如果你想得到更详细的反馈，可以与我们单独讨论。
> 
> 
> 


.



> 
> 11 月 9 日：在 [提交网站](https://6828.scripts.mit.edu/2018/handin.py/) 上提交一个提议，只需要一到两个段落就可以。提议要包括你的小组成员列表、你的计划、以及明确的设计和实现打算。（如果你做实验 6，就不用做这个了）
> 
> 
> 


.



> 
> 12 月 7 日：和你的简短报告一起提交源代码。将你的报告放在与名为 “README.pdf” 的文件相同的目录下。由于你只是这个实验任务小组中的一员，你可能需要去使用 git 在小组成员之间共享你的项目代码。因此你需要去决定哪些源代码将作为你的小组项目的共享起始点。一定要为你的最终项目去创建一个分支，并且命名为 `lab7`。（如果你做了实验 6，就按实验 6 的提交要求做即可。）
> 
> 
> 


.



> 
> 12 月 11 日这一周：简短的课堂演示。为你的 JOS 项目准备一个简短的课堂演示。为了你的项目演示，我们将提供一个投影仪。根据小组数量和每个小组选择的项目类型，我们可能会限制总的演讲数，并且有些小组可能最终没有机会上台演示。
> 
> 
> 


.



> 
> 12 月 11 日这一周：助教们验收。向助教演示你的项目，因此我们可能会提问一些问题，去了解你所做的一些细节。
> 
> 
> 


### 项目想法


如果你不做实验 6，下面是一个启迪你的想法列表。但是，你应该大胆地去实现你自己的想法。其中一些想法只是一个开端，并且本身不在实验 6 的领域内，并且其它的可能是在更大的领域中。


* 使用 [x86 虚拟机支持](http://www.intel.com/technology/itj/2006/v10i3/1-hardware/3-software.htm) 去构建一个能够运行多个访客系统（比如，多个 JOS 实例）的虚拟机监视器。
* 使用 Intel SGX 硬件保护机制做一些有用的事情。[这是使用 Intel SGX 的最新的论文](https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-baumann.pdf)。
* 让 JOS 文件系统支持写入、文件创建、为持久性使用日志、等等。或许你可以从 Linux EXT3 上找到一些启示。
* 从 [软更新](http://www.ece.cmu.edu/%7Eganger/papers/osdi94.pdf)、[WAFL](https://ng.gnunet.org/sites/default/files/10.1.1.40.3691.pdf)、ZFS、或其它较高级的文件系统上找到一些使用文件系统的想法。
* 给一个文件系统添加快照功能，以便于用户能够查看过去的多个时间点上的文件系统。为了降低空间使用量，你或许要使用一些写时复制技术。
* 使用分页去提供实时共享的内存，来构建一个 [分布式的共享内存](http://www.cdf.toronto.edu/%7Ecsc469h/fall/handouts/nitzberg91.pdf)（DSM）系统，以便于你在一个机器集群上运行多线程的共享内存的并行程序。当一个线程尝试去访问位于另外一个机器上的页时，页故障将给 DSM 系统提供一个机会，让它基于网络去从当前存储这个页的任意一台机器上获取这个页。
* 允许进程在机器之间基于网络进行迁移。你将需要做一些关于一个进程状态的多个片段方面的事情，但是由于在 JOS 中许多状态是在用户空间中，它或许从 Linux 上的进程迁移要容易一些。
* 在 JOS 中实现 [分页](http://en.wikipedia.org/wiki/Paging) 到磁盘，这样那个进程使用的内存就可以大于真实的内存。使用交换空间去扩展你的内存。
* 为 JOS 实现文件的 [mmap()](http://en.wikipedia.org/wiki/Mmap)。
* 使用 [xfi](http://static.usenix.org/event/osdi06/tech/erlingsson.html) 将一个进程的代码沙箱化。
* 支持 x86 的 [2MB 或 4MB 的页大小](http://en.wikipedia.org/wiki/Page_(computer_memory))。
* 修改 JOS 让内核支持进程内的线程。从查看 [课堂上的 uthread 任务](http://pdos.csail.mit.edu/6.828/2018/homework/xv6-uthread.html) 去开始。实现调度器触发将是实现这个项目的一种方式。
* 在 JOS 的内核中或文件系统中（实现多线程之后），使用细粒度锁或无锁并发。Linux 内核使用 [读复制更新](http://en.wikipedia.org/wiki/Read-copy-update) 去执行无需上锁的读取操作。通过在 JOS 中实现它来探索 RCU，并使用它去支持无锁读取的名称缓存。
* 实现 [外内核论文](http://pdos.csail.mit.edu/6.828/2018/readings/engler95exokernel.pdf) 中的想法。例如包过滤器。
* 使 JOS 拥有软实时行为。用它来辨识一些应用程序时非常有用。
* 使 JOS 运行在 64 位 CPU 上。这包括重设计虚拟内存让它使用 4 级页表。有关这方面的文档，请查看 [参考页](http://pdos.csail.mit.edu/6.828/2018/reference.html)。
* 移植 JOS 到一个不同的微处理器。这个 [osdev wiki](http://wiki.osdev.org/Main_Page) 或许对你有帮助。
* 为 JOS 系统增加一个“窗口”系统，包括图形驱动和鼠标。有关这方面的文档，请查看 [参考页](http://pdos.csail.mit.edu/6.828/2018/reference.html)。[sqrt(x)](http://web.mit.edu/amdragon/www/pubs/sqrtx-6.828.html) 就是一个 JOS “窗口” 系统的示例。
* 在 JOS 中实现 [dune](https://www.usenix.org/system/files/conference/osdi12/osdi12-final-117.pdf)，以提供特权硬件指令给用户空间应用程序。
* 写一个用户级调试器，添加类似跟踪的功能；硬件寄存器概要（即：Oprofile）；调用跟踪等等。
* 为（静态的）Linux 可运行程序做一个二进制仿真。




---


via: <https://pdos.csail.mit.edu/6.828/2018/labs/lab7/>


作者：[csail.mit](https://pdos.csail.mit.edu) 选题：[lujun9972](https://github.com/lujun9972) 译者：[qhwdw](https://github.com/qhwdw) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
# Lab 7: Final JOS project

**
Piazza Discussion Due, November 2, 2018 **

Proposals Due, November 8, 2018

Code repository Due, December 6, 2018

Check-off and in-class demos, Week of December 10, 2018

## Introduction

For the final project you have two options:

- Work on your own and do
[lab 6](../lab6/index.html), including
one challenge exercise in lab 6. (You are free, of course, to extend lab 6,
or any part of JOS, further in interesting ways, but it isn't required.)
- Work in a team of one, two or three, on a project of your choice that
involves your JOS. This project must be of the same scope as lab 6 or larger
(if you are working in a team).

The goal is to have fun and explore more advanced O/S topics; you don't have to
do novel research.

If you are doing your own project, we'll grade you on how much you got
working, how elegant your design is, how well you can explain it, and how
interesting and creative your solution is. We do realize that time is limited,
so we don't expect you to re-write Linux by the end of the semester. Try to make
sure your goals are reasonable; perhaps set a minimum goal that's definitely
achievable (e.g., something of the scale of lab 6) and a more ambitious goal if
things go well.

If you are doing lab 6, we will grade you on whether you pass the tests and
the challenge exercise.

## Deliverables

Nov 3: Piazza discussion and form groups of 1, 2, or 3 (depending on which
final project option you are choosing). Use the lab7
tag/folder on Piazza. Discuss ideas with others in comments on their Piazza
posting. Use these postings to help find other students interested in similar
ideas for forming a group. Course staff will provide feedback on project ideas
on Piazza; if you'd like more detailed feedback, come chat with us in
person.

Nov 9: Submit a proposal at [ the submission website](https://6828.scripts.mit.edu/2018/handin.py/),
just a paragraph or two. The proposal should include your group members list,
the problem you want to address, how you plan to address it, and what are you
proposing to specifically design and implement. (If you are doing lab 6, there
is nothing to do for this deliverable.)

Dec 7: submit source code along with a brief write-up.
Put the write-up under the top-level source directory with the
name "`README.pdf`". Since some of you will be working in groups for this lab assignment, you may
want to use git to share your project code between group members. You will need
to decide on whose source code you will use as a starting point for your group
project. Make sure to create a branch for your final project, and name it
**lab7**. (If you do lab 6, follow the lab 6 submission instructions.)

Week of Dec 11: short in-class demonstration. Prepare a short in-class
demo of your JOS project. We will provide a projector that you can use to
demonstrate your project. Depending on the number of groups and the kinds of
projects that each group chooses, we may decide to limit the total number of
presentations, and some groups might end up not presenting in class.

Week of Dec 11: check-off with TAs. Demo your project to the TAs so that
we can ask you some questions and find out in more detail what you did.

## Project ideas

If you are not doing lab 6, here's a list of ideas to get you started
thinking. But, you should feel free to pursue your own ideas. Some of the ideas
are starting points and by themselves not of the scope of lab 6, and others are
likely to be much of larger scope.

- Build a virtual machine monitor that can run multiple guests (for
example, multiple instances of JOS), using
[x86 VM support](http://www.intel.com/technology/itj/2006/v10i3/1-hardware/3-software.htm).
- Do something useful with the hardware protection of Intel SGX.
[Here
is a recent paper using Intel SGX](https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-baumann.pdf).
- Make the JOS file system support writing, file creation, logging for
durability, etc., perhaps taking ideas from Linux EXT3.
- Use file system ideas from
[Soft
updates](http://www.ece.cmu.edu/~ganger/papers/osdi94.pdf),
[WAFL](https://ng.gnunet.org/sites/default/files/10.1.1.40.3691.pdf),
ZFS, or another advanced file system.
- Add snapshots to a file system, so that a user can look at
the file system as it appeared at various points in the past.
You'll probably want to use some kind of copy-on-write for disk
storage to keep space consumption down.
- Build a
[distributed shared memory](http://www.cdf.toronto.edu/~csc469h/fall/handouts/nitzberg91.pdf) (DSM) system, so that you can run
multi-threaded shared memory parallel programs on a cluster of
machines, using paging to give the appearance of real shared memory.
When a thread tries to access a page that's on another machine, the
page fault will give the DSM system a chance to fetch the page over
the network from whatever machine currently stores it.
- Allow processes to migrate from one machine to another over the
network. You'll need to do something about the various pieces of a process's
state, but since much state in JOS is in user-space it may be easier than
process migration on Linux.
- Implement
[paging](http://en.wikipedia.org/wiki/Paging) to disk
in JOS, so that processes can be bigger than RAM. Extend your pager
with swapping.
- Implement
[mmap()](http://en.wikipedia.org/wiki/Mmap) of files
for JOS.
- Use
[xfi](http://static.usenix.org/event/osdi06/tech/erlingsson.html) to
sandbox code within a process.
- Support x86
[2MB or 4MB pages](http://en.wikipedia.org/wiki/Page_(computer_memory)).
- Modify JOS to have kernel-supported threads inside processes. See
[in-class
uthread assignment](http://pdos.csail.mit.edu/6.828/2018/homework/xv6-uthread.html) to get started. Implementing scheduler activations
would be one way to do this project.
- Use fine-grained locking or lock-free concurrency in JOS in the kernel or
in the file server (after making it multithreaded). The linux kernel uses
[read copy
update](http://en.wikipedia.org/wiki/Read-copy-update) to be able to perform read operations without holding locks.
Explore RCU by implementing it in JOS and use it to support a name cache with
lock-free reads.
- Implement ideas from the
[Exokernel papers](http://pdos.csail.mit.edu/6.828/2018/readings/engler95exokernel.pdf), for example the packet filter.
- Make JOS have soft real-time behavior. You will have to identify some
application for which this is useful.
- Make JOS run on 64-bit CPUs. This includes redoing the virtual
memory system to use 4-level pages tables. See
[reference page](http://pdos.csail.mit.edu/6.828/2018/reference.html)
for some documentation.
- Port JOS to a different microprocessor. The
[osdev wiki](http://wiki.osdev.org/Main_Page) may be helpful.
- A window system for JOS, including graphics driver and mouse. See
[reference
page](http://pdos.csail.mit.edu/6.828/2018/reference.html) for some documentation. [sqrt(x)](http://web.mit.edu/amdragon/www/pubs/sqrtx-6.828.html) is
an example JOS window system (and writeup).
- Implement
[dune](https://www.usenix.org/system/files/conference/osdi12/osdi12-final-117.pdf)
to export privileged hardware instructions to user-space applications in JOS.
- Write a user-level debugger; add strace-like functionality;
hardware register profiling (e.g. Oprofile); call-traces
- Binary emulation for (static) Linux executables