边界、依赖与验收
用 Go 实现具备任务调度与失败恢复能力的 MapReduce 协调器和工作进程。
发布 Lab 1;理解 MapReduce 执行模型
RPC 与并发为 coordinator/worker 通信打底
完整 MapReduce,23:59
实验目标与系统边界
本页可离线完成Handout 完整本土化
本实验中,你将构建一个 MapReduce 系统。你要实现 worker 进程:调用应用提供的 Map 和 Reduce 函数,并负责读写文件;还要实现 coordinator 进程:向 worker 分配任务,并处理 worker 失败。你构建的系统与 MapReduce 论文描述的系统相似。(本实验使用 coordinator 一词,而论文使用 master。)
系统由两个程序组成:一个 coordinator 和一个或多个并行运行的 worker。真实系统会把 worker 放在不同机器上,本实验则让它们在同一台机器运行。worker 通过 RPC 与 coordinator 通信,并循环执行:请求任务、读取一个或多个输入文件、执行任务、把结果写到一个或多个文件,然后再次请求任务。
coordinator 如果发现某个 worker 在合理时间内没有完成任务,应把同一个任务交给另一个 worker。本实验规定超时为 10 秒。coordinator 无法可靠地区分 worker 崩溃、卡住和只是很慢,因此重复分配是协议的正常路径。
获取代码与保留上游文件
本页可离线完成Handout 完整本土化
先按本页后面的 Go 环境说明安装 Go 1.22 或更高版本。使用 Git 获取初始实验代码:
git clone git://g.csail.mit.edu/6.5840-golabs-2026 6.5840
cd 6.5840
ls你应看到 Makefile 和 src。课程可能更新提供的代码;为了以后能用 git pull 顺利获取并合并更新,最好把课程提供的文件保留在原位置。可以按 handout 指示在这些文件中添加代码,但不要移动它们;你可以把自己的新函数放进新文件。
运行顺序版并理解应用接口
本页可离线完成Handout 完整本土化
课程在 src/main/mrsequential.go 提供了简单的顺序 MapReduce:所有 Map 和 Reduce 在单进程内逐个运行。还提供两个应用:mrapps/wc.go 的词频统计和 mrapps/indexer.go 的文本索引。运行词频统计:
cd ~/6.5840/src/main
go build -buildmode=plugin ../mrapps/wc.go
rm mr-out*
go run mrsequential.go wc.so pg*.txt
sort mr-out-0输出开头应类似:
A 509
ABOUT 2
ACT 8
ACTRESS 1
...如果 sort 顺序不同,可能需要使用 LC_COLLATE=C sort mr-out-0。顺序实现把结果留在 mr-out-0,输入来自 pg-xxx.txt。你可以借用 mrsequential.go 的代码,并应阅读 mrapps/wc.go,理解应用的 Map/Reduce 函数签名与 KeyValue 数据。
需要实现的文件与入口约束
本页可离线完成Handout 完整本土化
coordinator 与 worker 的 main 函数位于 main/mrcoordinator.go 和 main/mrworker.go,不要修改这些文件。你的实现应放在 mr/coordinator.go、mr/worker.go 和 mr/rpc.go。
Map 阶段必须把中间 key 分到 nReduce 个桶;nReduce 是 Reduce task 数,由 main/mrcoordinator.go 传给 MakeCoordinator()。每个 mapper 应创建 nReduce 个供 Reduce task 使用的中间文件。
第 X 个 Reduce task 的输出必须写入 mr-out-X。文件中每一行对应一次 Reduce 函数输出,使用 Go 格式 "%v %v",参数依次为 key 与 value;main/mrsequential.go 中注释 this is the correct format 的代码是准确参考。格式偏差会导致测试失败。
worker 应把 Map 中间文件写在当前目录,以便之后的 Reduce task 读取。main/mrcoordinator.go 要求 mr/coordinator.go 实现 Done();只有整个作业完全结束时它才返回 true,随后 coordinator main 退出。作业完成后 worker 进程也应退出。
手工启动 coordinator 与多个 worker
本页可离线完成Handout 完整本土化
先构建词频插件:
cd ~/6.5840/src/main
go build -buildmode=plugin ../mrapps/wc.go在第一个终端运行 coordinator:
rm mr-out*
go run mrcoordinator.go sock123 pg-*.txtsock123 指定 coordinator 接收 worker RPC 的 socket;pg-*.txt 是输入文件,每个文件对应一个 split,也就是一个 Map task 的输入。
在一个或多个其他终端启动 worker:
go run mrworker.go wc.so sock123全部完成后检查 mr-out-*。所有文件的排序并集必须与顺序实现相同:
cat mr-out-* | sort | more一个简单的 worker 退出办法是:如果 call() 无法再联系 coordinator,就假定 coordinator 因作业完成已经退出,worker 也结束。也可以让 coordinator 返回一个“请退出”的伪任务。实现必须避免在作业尚未完成的短暂 RPC 错误下过早丢弃必要工作。
官方测试、预期失败与完整通过输出
本页可离线完成Handout 完整本土化
所有评分测试都已提供,源码位于 mr/mr_test.go。在 src 目录运行:
cd ~/6.5840/src
make mr测试检查:wc 与 indexer 输出正确;Map/Reduce task 确实并行;worker 在 task 中崩溃后系统能恢复。初始空实现会在首个测试挂住。可暂时把 mr/coordinator.go 的 Done() 中 ret := false 改为 true,使 coordinator 立即退出;此时测试会报告没有 mr-out-X 输出,这是预期的基线失败。
完成后应通过 TestWc、TestIndexer、TestMapParallel、TestReduceParallel、TestJobCount、TestEarlyExit 与 TestCrashWorker,并在 go test -v -race 下没有 race。完整套件可能约需 1–2 分钟。
根据 worker 终止策略,每次测试偶尔出现类似以下错误是允许的,因为 coordinator 已退出而 worker 仍尝试连接:
dialing:dial unix /var/tmp/5840-mr-501: connect: connection refused应只有少量此类消息;大量持续重试通常表示退出条件有问题。
中间文件、分桶、排序与原子发布提示
本页可离线完成Handout 完整本土化
一个合理的中间文件命名是 mr-X-Y,X 为 Map task 编号,Y 为 Reduce task 编号。Map worker 可用 worker.go 的 ihash(key) 选择 Reduce task。
中间键值对必须能被 Reduce worker可靠读回。可以使用 encoding/json:
enc := json.NewEncoder(file)
for _, kv := range kva {
err := enc.Encode(&kv)
// 处理 err
}读取时:
dec := json.NewDecoder(file)
for {
var kv KeyValue
if err := dec.Decode(&kv); err != nil {
break
}
kva = append(kva, kv)
}可从 mrsequential.go 借用读取 Map 输入、排序 Reduce 中间键值对和写最终输出的代码。应用 Map/Reduce 函数通过 Go plugin 在运行时加载,插件文件以 .so 结尾。修改 mr/ 后通常要重新 go build -buildmode=plugin ../mrapps/wc.go;make mr 会自动构建插件。
为避免崩溃时其他进程看到半写文件,先用 ioutil.TempFile(Go 1.17+ 可用 os.CreateTemp)写临时文件,完整关闭后用 os.Rename 原子改为目标名。Map 和 Reduce 输出都应考虑多个尝试并发完成。
调度、并发、等待与失败恢复提示
本页可离线完成Handout 完整本土化
推荐的第一步:让 mr/worker.go 的 Worker() 向 coordinator 发 RPC 请求任务;coordinator 先只返回一个尚未开始的 Map 输入文件;worker 读取文件并像顺序版一样调用 Map。先打通一条正常路径,再扩展状态机。
coordinator 作为 RPC server 会并发执行 handler,必须用锁保护共享任务状态。Reduce 不能在最后一个 Map 完成前开始。无工作可做时,worker 可周期性请求并 time.Sleep();也可让 RPC handler 用循环配合 Sleep 或 sync.Cond 等待。每个 RPC handler 在独立 goroutine 中执行,一个等待不应阻止其他 handler。
coordinator 对进行中任务计时,10 秒未完成就可重新分配。原 worker 可能仍会完成并报告,所以完成 handler 必须幂等,不能让迟到报告破坏已经接受的新尝试。若实现论文的 backup tasks,正常 worker 未崩溃时不得调度多余任务;只有较长时间(如 10 秒)后才能备份。
用 mrapps/crash.go 随机在 Map/Reduce 中退出,测试恢复。worker 共享文件系统是本实验假设;跨机器运行需要 GFS/AFS/S3 等共享存储,并把 RPC 从 Unix socket 改为 TCP/IP。
Go RPC 字段与 reply 初始化规则
本页可离线完成Handout 完整本土化
Go RPC 只传输名称以大写字母开头的 struct 字段;嵌套结构的字段也必须导出。请求和响应类型应放在 mr/rpc.go,让 coordinator 与 worker 使用同一协议定义。
调用课程给出的 call() 时,reply struct 必须从全零值开始:
reply := SomeType{}
call(..., &reply)不要在调用前给 reply 任意字段设置非默认值;否则 RPC 系统可能静默返回错误值。区分“RPC 调用失败”和“coordinator 成功返回等待/退出任务”,不要用未初始化字段猜测响应类型。
Go 1.22+ 环境:macOS、Linux 与 Windows
本页可离线完成Handout 完整本土化
所有实验使用 Go。请使用 Go 1.22 或更高版本,并运行 go version 检查。建议在自己的机器上完成,以使用熟悉的编辑器和工具;VS Code 有 Go 扩展,GoLand 提供免费教育许可。课程可在 Piazza/office hours 协助配置;实验大概率无法直接在 Athena 上运行。
macOS:安装 Homebrew 后运行:
brew install goLinux:可用发行版仓库的新版,例如 apt install golang;否则确认 uname -a 显示 64 位 x86_64 GNU/Linux,再手工安装:
wget -qO- https://go.dev/dl/go1.23.5.linux-amd64.tar.gz | sudo tar xz -C /usr/local把 /usr/local/go/bin 放入 PATH,例如在 .bashrc、.bash_profile 或 .zshrc 中加入:
export PATH=$PATH:/usr/local/go/binWindows:课程认为实验可在 WSL2 中运行。安装 Windows Subsystem for Linux,再从 Microsoft Store 安装 Ubuntu 24.04,然后按 Linux 步骤配置。必须是 WSL 2,WSL 1 不支持;在 Windows 终端运行 wsl -l -v,确认版本为 2 且 Ubuntu 版本正确。
协作与代码保密政策(完整翻译)
本页可离线完成Handout 完整本土化
除课程作为作业一部分提供的代码外,你提交给 6.5840 的所有代码都必须由你自己编写。不得查看任何其他人的解答,也不得查看往年 6.5840 或 6.824 的解答。可以和其他同学讨论作业,但不得查看或复制彼此的代码。制定这条规则,是因为课程认为亲自设计并实现实验解答能获得最多学习。
请不要公开发布你的代码,也不要让当前或未来的 6.5840 学生能够访问。GitHub 仓库默认公开,所以除非明确设为 private,不要把代码放在那里。可以使用 MIT GitHub,但务必创建私有仓库。
提交步骤与迟交时间计算(完整翻译)
本页可离线完成Handout 完整本土化
提交前,请最后再运行一次所有测试。使用 make labnp 打包实验,并把生成的 labnp-handin.tar.gz 上传到 Gradescope。其中 n 是实验编号(1、2、3 或 4),p 是分段编号(如 A、B、C;仅当实验分段时使用)。
例如:
cd ~/6.5840
make lab1或:
cd ~/6.5840
make lab3a提交后续 part 前,确认之前的 part 仍然工作,也就是运行截至当前提交 part 的全部测试。可以多次提交;课程以最后一次提交的时间戳计算 late days。
不计分挑战练习
本页可离线完成Handout 完整本土化
挑战一:实现自己的 MapReduce 应用,可参考 mrapps/*,例如 MapReduce 论文 2.3 节的 Distributed Grep。
挑战二:让 coordinator 和 worker 像真实系统一样运行在不同机器。需要把 Coordinator.server() 中 RPC 从 Unix socket 改为 TCP/IP,并使用共享文件系统读写。可以 SSH 到 MIT Athena cluster 机器并使用 AFS,或租用 AWS 实例并使用 S3。
这些练习不计分,不应影响必做功能和测试稳定性。
完整官方 Handout 与配套资料
以下是本讲对应官方材料的可搜索离线文本。中文精读负责解释;资料附录保留原始细节、例子、问答与代码,不以摘要替代原文。
网页讲义labs/lab-mr.html362 行 · 2,108 词 · 完整收录
6.5840 Lab 1: MapReduce
6.5840 - Spring 2026
6.5840 Lab 1: MapReduce
Collaboration policy //
Submit lab //
Setup Go //
Guidance //
Piazza
Introduction
In this lab you'll build a MapReduce system.
You'll implement a worker process that calls application Map and Reduce
functions and handles reading and writing files,
and a coordinator process that hands out tasks to
workers and copes with failed workers.
You'll be building something similar to the
MapReduce paper.
(Note: this lab uses "coordinator" instead of the paper's "master".)
Getting started
You need to setup Go to do the labs.
Fetch the initial lab software with
git (a version control system).
To learn more about git, look at the
Pro Git book or the
git user's manual.
$ git clone git://g.csail.mit.edu/6.5840-golabs-2026 6.5840
$ cd 6.5840
$ ls
Makefile src
$
We supply you with a simple sequential mapreduce implementation in
src/main/mrsequential.go. It runs the maps and reduces one at a
time, in a single process. We also
provide you with a couple of MapReduce applications: word-count
in mrapps/wc.go, and a text indexer
in mrapps/indexer.go. You can run
word count sequentially as follows:
$ cd ~/6.5840
$ cd src/main
$ go build -buildmode=plugin ../mrapps/wc.go
$ rm mr-out*
$ go run mrsequential.go wc.so pg*.txt
$ sort mr-out-0
A 509
ABOUT 2
ACT 8
ACTRESS 1
...
(You might
need to set LC_COLLATE=C environment variable for
sort to produce the above output: LC_COLLATE=C sort mr-out-0)
mrsequential.go leaves its output in the file mr-out-0.
The input is from the text files named pg-xxx.txt.
Feel free to borrow code from mrsequential.go.
You should also have a look at mrapps/wc.go to see what
MapReduce application code looks like.
For this lab and all the others, we might issue updates to the code we
provide you. To ensure that you can fetch those updates and easily
merge them using git pull, it's best to leave the code we
provide in the original files. You can add to the code we provide as
directed in the lab write-ups; just don't move it. It's OK to put your
own new functions in new files.
Your Job
Your job is to implement a distributed MapReduce, consisting of
two programs, the coordinator and the worker. There will be
just one coordinator process, and one or more worker processes executing in
parallel. In a real system the workers would run on a bunch of
different machines, but for this lab you'll run them all on a single machine.
The workers will talk to the coordinator via RPC. Each worker process will,
in a loop, ask
the coordinator for a task, read the task's input from one or more files,
execute the task, write the task's output to one
or more files, and again ask the coordinator for a
new task. The coordinator should notice if a worker hasn't completed
its task in a reasonable amount of time (for this lab, use ten
seconds), and give the same task to a different worker.
We have given you a little code to start you off. The "main" routines for
the coordinator and worker are in main/mrcoordinator.go and main/mrworker.go;
don't change these files. You should put your implementation in mr/coordinator.go,
mr/worker.go, and mr/rpc.go.
Here's how to run your code on the word-count MapReduce
application. First, build the word-count plugin:
$ cd main
$ go build -buildmode=plugin ../mrapps/wc.go
In one window, run the coordinator:
$ rm mr-out*
$ go run mrcoordinator.go sock123 pg-*.txt
The sock123 argument specifies a socket on which the
coordinator receives RPCs from workers.
The pg-*.txt arguments to mrcoordinator.go are
the input files; each file corresponds to one "split", and is the
input to one Map task.
In one or more other windows, run some workers:
$ go run mrworker.go wc.so sock123
When the workers and coordinator have finished, look at the output
in mr-out-*. When you've completed the lab, the
sorted union of the output files should match the sequential
output, like this:
$ cat mr-out-* | sort | more
A 509
ABOUT 2
ACT 8
ACTRESS 1
...
We supply you with all the tests that we'll use to grade your submitted
lab. The source code for the tests are in mr/mr_test.go.
You can run the tests in the src directory:
$ cd src
$ make mr
...
The tests check that the wc and indexer MapReduce
applications produce the correct output when given
the pg-xxx.txt files as input. The tests also check that your
implementation runs the Map and Reduce tasks in parallel, and that
your implementation recovers from workers that crash while running
tasks.
If you run the tests now, they will hang in the first test:
$ cd ~/6.5840/src
$ make mr
...
cd mr; go test -v -race
=== RUN TestWc
...
You can change ret := false to true in the Done function in mr/coordinator.go
so that the coordinator exits immediately. Then:
$ make mr
...
=== RUN TestWc
2026/01/22 14:56:24 reduce created no mr-out-X output files!
exit status 1
FAIL 6.5840/mr 4.516s
make: *** [Makefile:44: mr] Error 1
$
The tests expect to see output in files named mr-out-X, one
for each reduce task. The empty implementations of mr/coordinator.go
and mr/worker.go don't produce those files (or do much of
anything else), so the test fails.
When you've finished, the test output should look like this:
$ make mr
...
=== RUN TestWc
--- PASS: TestWc (8.64s)
=== RUN TestIndexer
--- PASS: TestIndexer (5.90s)
=== RUN TestMapParallel
--- PASS: TestMapParallel (7.05s)
=== RUN TestReduceParallel
--- PASS: TestReduceParallel (8.05s)
=== RUN TestJobCount
--- PASS: TestJobCount (10.04s)
=== RUN TestEarlyExit
--- PASS: TestEarlyExit (6.05s)
=== RUN TestCrashWorker
2026/01/22 14:58:14 *re*-starting map ../../main/pg-tom_sawyer.txt 0
2026/01/22 14:58:14 *re*-starting map ../../main/pg-metamorphosis.txt 2
2026/01/22 14:58:39 *re*-starting map ../../main/pg-metamorphosis.txt 2
2026/01/22 14:58:40 map 2 already done
2026/01/22 14:58:45 *re*-starting reduce 0
--- PASS: TestCrashWorker (40.18s)
PASS
ok 6.5840/mr 86.932s
$
Depending on your strategy for terminating worker processes, you may see errors like:
2026/02/11 16:21:32 dialing:dial unix /var/tmp/5840-mr-501: connect: connection refused
It is fine to see a handful of these messages per test; they arise when the worker is unable to contact the coordinator RPC server after
the coordinator has exited.
A few rules:
The map phase should divide the intermediate keys into buckets for
nReduce reduce tasks,
where nReduce is the number of reduce tasks -- the argument that
main/mrcoordinator.go passes to MakeCoordinator().
Each mapper should create nReduce intermediate files for
consumption by the reduce tasks.
The worker implementation should put the output of the X'th
reduce task in the file mr-out-X.
A mr-out-X file should contain one line per Reduce
function output. The line should be generated with the Go "%v %v"
format, called with the key and value. Have a look in main/mrsequential.go
for the line commented "this is the correct format".
The tests will fail if your implementation deviates too much from this format.
You can modify mr/worker.go, mr/coordinator.go, and mr/rpc.go.
You can temporarily modify other files for testing, but make sure your code works
with the original versions; we'll test with the original versions.
The worker should put intermediate Map output in files in the current
directory, where your worker can later read them as input to Reduce tasks.
main/mrcoordinator.go expects mr/coordinator.go to implement a
Done() method that returns true when the MapReduce job is completely finished;
at that point, mrcoordinator.go will exit.
When the job is completely finished, the worker processes should exit.
A simple way to implement this is to use the return value from call():
if the worker fails to contact the coordinator, it can assume that the coordinator has exited
because the job is done, so the worker can terminate too. Depending on your
design, you might also find it helpful to have a "please exit" pseudo-task
that the coordinator can give to workers.
Hints
The Guidance page has some
tips on developing and debugging.
One way to get started is to modify mr/worker.go's
Worker() to send an RPC to the coordinator asking for a task. Then
modify the coordinator to respond with the file name of an as-yet-unstarted
map task. Then modify the worker to read that file and call the
application Map function, as in mrsequential.go.
The application Map and Reduce functions are loaded at run-time
using the Go plugin package, from files whose names end in .so.
If you change anything in the mr/ directory, you will
probably have to re-build any MapReduce plugins you use, with
something like go build -buildmode=plugin ../mrapps/wc.go.
make mr builds the plugins for you. You can run an
individual test using make RUN="-run Wc" mr`, which passes
"-run Wc" to go go test, and selects any test
from mr/mr_test.go matching Wc.
This lab relies on the workers sharing a file system.
That's straightforward when all workers run on the same machine, but would require a global
filesystem like GFS if the workers ran on different machines.
A reasonable naming convention for intermediate files is mr-X-Y,
where X is the Map task number, and Y is the reduce task number.
The worker's map task code will need a way to store intermediate
key/value pairs in files in a way that can be correctly read back
during reduce tasks. One possibility is to use Go's encoding/json package. To
write key/value pairs in JSON format to an open file:
enc := json.NewEncoder(file)
for _, kv := ... {
err := enc.Encode(&kv)
and to read such a file back:
dec := json.NewDecoder(file)
for {
var kv KeyValue
if err := dec.Decode(&kv); err != nil {
break
}
kva = append(kva, kv)
}
The map part of your worker can use the ihash(key) function
(in worker.go) to pick the reduce task for a given key.
You can steal some code from mrsequential.go for reading
Map input files, for sorting intermedate key/value pairs between the
Map and Reduce, and for storing Reduce output in files.
The coordinator, as an RPC server, will be concurrent; don't forget
to lock shared data.
Workers will sometimes need to wait, e.g. reduces can't start
until the last map has finished. One possibility is for workers to
periodically ask the coordinator for work, sleeping
with time.Sleep() between each request. Another possibility
is for the relevant RPC handler in the coordinator to have a loop that
waits, either with time.Sleep() or sync.Cond. Go
runs the handler for each RPC in its own thread, so the fact that one
handler is waiting needn't prevent the coordinator from processing other
RPCs.
The coordinator can't reliably distinguish between crashed workers,
workers that are alive but have stalled for some reason,
and workers that are executing but too slowly to be useful.
The best you can do is have the coordinator wait for
some amount of time, and then give up and re-issue the task to
a different worker. For this lab, have the coordinator wait for
ten seconds; after that the coordinator should assume the worker has
died (of course, it might not have).
If you choose to implement Backup Tasks (Section 3.6), note that we test that your code doesn't
schedule extraneous tasks when workers execute tasks without crashing. Backup tasks should only
be scheduled after some relatively long period of time (e.g., 10s).
To test crash recovery, you can use the mrapps/crash.go
application plugin. It randomly exits in the Map and Reduce functions.
To ensure that nobody observes partially written files in the presence of
crashes, the MapReduce paper mentions the trick of using a temporary file
and atomically renaming it once it is completely written. You can use
ioutil.TempFile (or os.CreateTemp if you are running
Go 1.17 or later) to create a temporary file and os.Rename
to atomically rename it.
Go RPC sends only struct fields whose names start with capital letters.
Sub-structures must also have capitalized field names.
When calling the RPC call() function, the
reply struct should contain all default values. RPC calls
should look like this:
reply := SomeType{}
call(..., &reply)
without setting any fields of reply before the call. If you
pass reply structures that have non-default fields, the RPC
system may silently return incorrect values.
No-credit challenge exercises
Implement your own MapReduce application (see examples in mrapps/*), e.g., Distributed
Grep (Section 2.3 of the MapReduce paper).
Get your MapReduce coordinator and workers to run on separate machines, as they would in practice.
You will need to set up your RPCs to communicate over TCP/IP instead of Unix sockets (see
the commented out line in Coordinator.server()), and read/write files using a shared file
system. For example, you can ssh into multiple
Athena cluster
machines at MIT, which use
AFS
to share files; or you could rent a couple AWS instances and use
S3 for storage.网页讲义labs/go.html59 行 · 322 词 · 完整收录
6.5840 Go
Go
You'll implement all the labs in
Go. The Go web site contains lots
of tutorial information. You should use Go 1.22 or any later version.
You can check your Go version by running go version.
We recommend that you work on the labs on your own machine, so you can
use the tools, text editors, etc. that you are already familiar with. Many
editors have plug-ins for Go, e.g.
the
Go extension for
VS Code. Some commercial IDEs like
GoLand have
free educational licenses.
We are happy to provide support over Piazza and in office hours to help
you set up Go.
The labs probably won't work on Athena.
macOS
You can use Homebrew to install Go. After
installing Homebrew, run brew install go.
Linux
Depending on your Linux distribution, you might be able to get an up-to-date
version of Go from the package repository, e.g. by running apt install
golang. Otherwise, you can manually install a binary from Go's website.
First, make sure that you're running a 64-bit kernel (uname -a should
mention "x86_64 GNU/Linux"), and then run:
$ wget -qO- https://go.dev/dl/go1.23.5.linux-amd64.tar.gz | sudo tar xz -C /usr/local
You'll need to make sure /usr/local/go/bin is on your PATH.
You can do this by adding export PATH=$PATH:/usr/local/go/bin to your
shell's init file ( commonly this is one of .bashrc, .bash_profile or .zshrc)
Windows
The labs are believed to work under Microsoft's WSL2 (Windows Subsystem for
Linux, version 2).
To use WSL 2, first make sure you have
the Windows
Subsystem for Linux installed. Then
add Ubuntu
24.04 from the Microsoft Store. Afterwards you should be able to
launch Ubuntu Linux. Then you can follow
the directions for Linux (above).
Make sure that you are running version 2 of WSL.
WSL 1 does not work with the labs.
To check,
run wsl -l -v in a Windows terminal to confirm that WSL
2 and the correct Ubuntu version are installed.网页讲义labs/collab.html19 行 · 145 词 · 完整收录
6.5840 Collaboration policy
Collaboration Policy
You must write all the code you hand in for 6.5840, except for code
that we give you as part of assignments. You are not allowed to
look at anyone else's solution, and you are not allowed to look at
solutions from previous 6.5840 or 6.824 years. You may discuss the assignments with
other students, but you may not look at or copy each others' code. The
reason for this rule is that we believe you will learn the most by
designing and implementing your lab solution yourself.
Please do not publish your code or make
it available to current or future 6.5840 students.
github.com repositories are public by default, so please
don't put your code there unless you make the repository private. You
may find it convenient to use
MIT's GitHub,
but be sure to create a private repository.网页讲义labs/submit.html28 行 · 119 词 · 完整收录
6.5840 Lab submission instructions
Handin procedure
Before submitting, please run all tests one final time.
Use the make labnp command to package your lab
assignment and upload the generated tarball labnp-handin.tar.gz
to Gradescope.
n is the lab number (i.e., 1, 2, 3, or 4) and p the part
(e.g, A, B, or C), if the lab is in parts.
For example:
$ cd ~/6.5840
$ make lab1
Or:
$ cd ~/6.5840
$ make lab3a
Before you submit a later part, make sure the earlier parts still work.
That is run, all tests through the part you are submitting.
You may submit multiple times. We will use the timestamp of
your last submission for the purpose of
calculating late days.