├── README.md ├── doc ├── project1.md ├── project2.md └── project3.md ├── pintos ├── ._.DS_Store ├── src │ ├── ._.DS_Store │ ├── .gitignore │ ├── LICENSE │ ├── Make.config │ ├── Makefile │ ├── Makefile.build │ ├── Makefile.kernel │ ├── Makefile.userprog │ ├── devices │ │ ├── block.c │ │ ├── block.h │ │ ├── ide.c │ │ ├── ide.h │ │ ├── input.c │ │ ├── input.h │ │ ├── intq.c │ │ ├── intq.h │ │ ├── kbd.c │ │ ├── kbd.h │ │ ├── partition.c │ │ ├── partition.h │ │ ├── pit.c │ │ ├── pit.h │ │ ├── rtc.c │ │ ├── rtc.h │ │ ├── serial.c │ │ ├── serial.h │ │ ├── shutdown.c │ │ ├── shutdown.h │ │ ├── speaker.c │ │ ├── speaker.h │ │ ├── timer.c │ │ ├── timer.h │ │ ├── vga.c │ │ └── vga.h │ ├── examples │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── bubsort.c │ │ ├── cat.c │ │ ├── cmp.c │ │ ├── cp.c │ │ ├── echo.c │ │ ├── halt.c │ │ ├── hex-dump.c │ │ ├── insult.c │ │ ├── lib │ │ │ ├── .gitignore │ │ │ └── user │ │ │ │ ├── .dummy │ │ │ │ └── .gitignore │ │ ├── lineup.c │ │ ├── ls.c │ │ ├── matmult.c │ │ ├── mcat.c │ │ ├── mcp.c │ │ ├── mkdir.c │ │ ├── pwd.c │ │ ├── recursor.c │ │ ├── rm.c │ │ └── shell.c │ ├── filesys │ │ ├── .gitignore │ │ ├── Make.vars │ │ ├── Makefile │ │ ├── directory.c │ │ ├── directory.h │ │ ├── file.c │ │ ├── file.h │ │ ├── filesys.c │ │ ├── filesys.h │ │ ├── free-map.c │ │ ├── free-map.h │ │ ├── fsutil.c │ │ ├── fsutil.h │ │ ├── inode.c │ │ ├── inode.h │ │ ├── off_t.h │ │ └── testfiles │ │ │ ├── test-buffer-write-full-blocks-persistence.ck │ │ │ ├── test-buffer-write-full-blocks.c │ │ │ ├── test-buffer-write-full-blocks.ck │ │ │ ├── test-cache-improvement-persistence.ck │ │ │ ├── test-cache-improvement.c │ │ │ └── test-cache-improvement.ck │ ├── lib │ │ ├── arithmetic.c │ │ ├── ctype.h │ │ ├── debug.c │ │ ├── debug.h │ │ ├── inttypes.h │ │ ├── kernel │ │ │ ├── bitmap.c │ │ │ ├── bitmap.h │ │ │ ├── console.c │ │ │ ├── console.h │ │ │ ├── debug.c │ │ │ ├── hash.c │ │ │ ├── hash.h │ │ │ ├── list.c │ │ │ ├── list.h │ │ │ └── stdio.h │ │ ├── limits.h │ │ ├── packed.h │ │ ├── random.c │ │ ├── random.h │ │ ├── round.h │ │ ├── stdarg.h │ │ ├── stdbool.h │ │ ├── stddef.h │ │ ├── stdint.h │ │ ├── stdio.c │ │ ├── stdio.h │ │ ├── stdlib.c │ │ ├── stdlib.h │ │ ├── string.c │ │ ├── string.h │ │ ├── syscall-nr.h │ │ ├── user │ │ │ ├── console.c │ │ │ ├── debug.c │ │ │ ├── entry.c │ │ │ ├── stdio.h │ │ │ ├── syscall.c │ │ │ ├── syscall.h │ │ │ └── user.lds │ │ ├── ustar.c │ │ └── ustar.h │ ├── misc │ │ ├── bochs-2.2.6-big-endian.patch │ │ ├── bochs-2.2.6-build.sh │ │ ├── bochs-2.2.6-gdbstub-ENN.patch │ │ ├── bochs-2.2.6-jitter.patch │ │ ├── bochs-2.2.6-ms-extensions.patch │ │ ├── bochs-2.2.6-namespace.patch │ │ ├── bochs-2.2.6-page-fault-segv.patch │ │ ├── bochs-2.2.6-paranoia.patch │ │ ├── bochs-2.2.6-solaris-link.patch │ │ ├── bochs-2.2.6-solaris-tty.patch │ │ ├── bochs-2.2.6-triple-fault.patch │ │ ├── gcc-3.3.6-cross-howto │ │ └── gdb-macros │ ├── tests │ │ ├── Algorithm │ │ │ └── Diff.pm │ │ ├── Make.tests │ │ ├── arc4.c │ │ ├── arc4.h │ │ ├── arc4.pm │ │ ├── cksum.c │ │ ├── cksum.h │ │ ├── cksum.pm │ │ ├── filesys │ │ │ ├── Grading.no-vm │ │ │ ├── Grading.with-vm │ │ │ ├── base │ │ │ │ ├── Make.tests │ │ │ │ ├── Rubric │ │ │ │ ├── child-syn-read.c │ │ │ │ ├── child-syn-wrt.c │ │ │ │ ├── full.inc │ │ │ │ ├── lg-create.c │ │ │ │ ├── lg-create.ck │ │ │ │ ├── lg-full.c │ │ │ │ ├── lg-full.ck │ │ │ │ ├── lg-random.c │ │ │ │ ├── lg-random.ck │ │ │ │ ├── lg-seq-block.c │ │ │ │ ├── lg-seq-block.ck │ │ │ │ ├── lg-seq-random.c │ │ │ │ ├── lg-seq-random.ck │ │ │ │ ├── random.inc │ │ │ │ ├── seq-block.inc │ │ │ │ ├── seq-random.inc │ │ │ │ ├── sm-create.c │ │ │ │ ├── sm-create.ck │ │ │ │ ├── sm-full.c │ │ │ │ ├── sm-full.ck │ │ │ │ ├── sm-random.c │ │ │ │ ├── sm-random.ck │ │ │ │ ├── sm-seq-block.c │ │ │ │ ├── sm-seq-block.ck │ │ │ │ ├── sm-seq-random.c │ │ │ │ ├── sm-seq-random.ck │ │ │ │ ├── syn-read.c │ │ │ │ ├── syn-read.ck │ │ │ │ ├── syn-read.h │ │ │ │ ├── syn-remove.c │ │ │ │ ├── syn-remove.ck │ │ │ │ ├── syn-write.c │ │ │ │ ├── syn-write.ck │ │ │ │ └── syn-write.h │ │ │ ├── create.inc │ │ │ ├── extended │ │ │ │ ├── Make.tests │ │ │ │ ├── Rubric.functionality │ │ │ │ ├── Rubric.persistence │ │ │ │ ├── Rubric.robustness │ │ │ │ ├── child-syn-rw.c │ │ │ │ ├── dir-empty-name-persistence.ck │ │ │ │ ├── dir-empty-name.c │ │ │ │ ├── dir-empty-name.ck │ │ │ │ ├── dir-mk-tree-persistence.ck │ │ │ │ ├── dir-mk-tree.c │ │ │ │ ├── dir-mk-tree.ck │ │ │ │ ├── dir-mkdir-persistence.ck │ │ │ │ ├── dir-mkdir.c │ │ │ │ ├── dir-mkdir.ck │ │ │ │ ├── dir-open-persistence.ck │ │ │ │ ├── dir-open.c │ │ │ │ ├── dir-open.ck │ │ │ │ ├── dir-over-file-persistence.ck │ │ │ │ ├── dir-over-file.c │ │ │ │ ├── dir-over-file.ck │ │ │ │ ├── dir-rm-cwd-persistence.ck │ │ │ │ ├── dir-rm-cwd.c │ │ │ │ ├── dir-rm-cwd.ck │ │ │ │ ├── dir-rm-parent-persistence.ck │ │ │ │ ├── dir-rm-parent.c │ │ │ │ ├── dir-rm-parent.ck │ │ │ │ ├── dir-rm-root-persistence.ck │ │ │ │ ├── dir-rm-root.c │ │ │ │ ├── dir-rm-root.ck │ │ │ │ ├── dir-rm-tree-persistence.ck │ │ │ │ ├── dir-rm-tree.c │ │ │ │ ├── dir-rm-tree.ck │ │ │ │ ├── dir-rmdir-persistence.ck │ │ │ │ ├── dir-rmdir.c │ │ │ │ ├── dir-rmdir.ck │ │ │ │ ├── dir-under-file-persistence.ck │ │ │ │ ├── dir-under-file.c │ │ │ │ ├── dir-under-file.ck │ │ │ │ ├── dir-vine-persistence.ck │ │ │ │ ├── dir-vine.c │ │ │ │ ├── dir-vine.ck │ │ │ │ ├── grow-create-persistence.ck │ │ │ │ ├── grow-create.c │ │ │ │ ├── grow-create.ck │ │ │ │ ├── grow-dir-lg-persistence.ck │ │ │ │ ├── grow-dir-lg.c │ │ │ │ ├── grow-dir-lg.ck │ │ │ │ ├── grow-dir.inc │ │ │ │ ├── grow-file-size-persistence.ck │ │ │ │ ├── grow-file-size.c │ │ │ │ ├── grow-file-size.ck │ │ │ │ ├── grow-root-lg-persistence.ck │ │ │ │ ├── grow-root-lg.c │ │ │ │ ├── grow-root-lg.ck │ │ │ │ ├── grow-root-sm-persistence.ck │ │ │ │ ├── grow-root-sm.c │ │ │ │ ├── grow-root-sm.ck │ │ │ │ ├── grow-seq-lg-persistence.ck │ │ │ │ ├── grow-seq-lg.c │ │ │ │ ├── grow-seq-lg.ck │ │ │ │ ├── grow-seq-sm-persistence.ck │ │ │ │ ├── grow-seq-sm.c │ │ │ │ ├── grow-seq-sm.ck │ │ │ │ ├── grow-seq.inc │ │ │ │ ├── grow-sparse-persistence.ck │ │ │ │ ├── grow-sparse.c │ │ │ │ ├── grow-sparse.ck │ │ │ │ ├── grow-tell-persistence.ck │ │ │ │ ├── grow-tell.c │ │ │ │ ├── grow-tell.ck │ │ │ │ ├── grow-two-files-persistence.ck │ │ │ │ ├── grow-two-files.c │ │ │ │ ├── grow-two-files.ck │ │ │ │ ├── mk-tree.c │ │ │ │ ├── mk-tree.h │ │ │ │ ├── syn-rw-persistence.ck │ │ │ │ ├── syn-rw.c │ │ │ │ ├── syn-rw.ck │ │ │ │ ├── syn-rw.h │ │ │ │ └── tar.c │ │ │ ├── seq-test.c │ │ │ └── seq-test.h │ │ ├── internal │ │ │ ├── list.c │ │ │ ├── stdio.c │ │ │ └── stdlib.c │ │ ├── lib.c │ │ ├── lib.h │ │ ├── lib.pm │ │ ├── main.c │ │ ├── main.h │ │ ├── make-grade │ │ ├── random.pm │ │ ├── tests.pm │ │ ├── threads │ │ │ ├── Grading │ │ │ ├── Make.tests │ │ │ ├── Rubric.alarm │ │ │ ├── Rubric.mlfqs │ │ │ ├── Rubric.priority │ │ │ ├── alarm-multiple.ck │ │ │ ├── alarm-negative.c │ │ │ ├── alarm-negative.ck │ │ │ ├── alarm-priority.c │ │ │ ├── alarm-priority.ck │ │ │ ├── alarm-simultaneous.c │ │ │ ├── alarm-simultaneous.ck │ │ │ ├── alarm-single.ck │ │ │ ├── alarm-wait.c │ │ │ ├── alarm-zero.c │ │ │ ├── alarm-zero.ck │ │ │ ├── alarm.pm │ │ │ ├── mlfqs-block.c │ │ │ ├── mlfqs-block.ck │ │ │ ├── mlfqs-fair-2.ck │ │ │ ├── mlfqs-fair-20.ck │ │ │ ├── mlfqs-fair.c │ │ │ ├── mlfqs-load-1.c │ │ │ ├── mlfqs-load-1.ck │ │ │ ├── mlfqs-load-60.c │ │ │ ├── mlfqs-load-60.ck │ │ │ ├── mlfqs-load-avg.c │ │ │ ├── mlfqs-load-avg.ck │ │ │ ├── mlfqs-nice-10.ck │ │ │ ├── mlfqs-nice-2.ck │ │ │ ├── mlfqs-recent-1.c │ │ │ ├── mlfqs-recent-1.ck │ │ │ ├── mlfqs.pm │ │ │ ├── priority-change.c │ │ │ ├── priority-change.ck │ │ │ ├── priority-condvar.c │ │ │ ├── priority-condvar.ck │ │ │ ├── priority-donate-chain.c │ │ │ ├── priority-donate-chain.ck │ │ │ ├── priority-donate-lower.c │ │ │ ├── priority-donate-lower.ck │ │ │ ├── priority-donate-multiple.c │ │ │ ├── priority-donate-multiple.ck │ │ │ ├── priority-donate-multiple2.c │ │ │ ├── priority-donate-multiple2.ck │ │ │ ├── priority-donate-nest.c │ │ │ ├── priority-donate-nest.ck │ │ │ ├── priority-donate-one.c │ │ │ ├── priority-donate-one.ck │ │ │ ├── priority-donate-sema.c │ │ │ ├── priority-donate-sema.ck │ │ │ ├── priority-fifo.c │ │ │ ├── priority-fifo.ck │ │ │ ├── priority-preempt.c │ │ │ ├── priority-preempt.ck │ │ │ ├── priority-sema.c │ │ │ ├── priority-sema.ck │ │ │ ├── tests.c │ │ │ └── tests.h │ │ ├── userprog │ │ │ ├── Grading │ │ │ ├── Make.tests │ │ │ ├── Rubric.functionality │ │ │ ├── Rubric.robustness │ │ │ ├── args-dbl-space.ck │ │ │ ├── args-many.ck │ │ │ ├── args-multiple.ck │ │ │ ├── args-none.ck │ │ │ ├── args-single.ck │ │ │ ├── args.c │ │ │ ├── bad-jump.c │ │ │ ├── bad-jump.ck │ │ │ ├── bad-jump2.c │ │ │ ├── bad-jump2.ck │ │ │ ├── bad-read.c │ │ │ ├── bad-read.ck │ │ │ ├── bad-read2.c │ │ │ ├── bad-read2.ck │ │ │ ├── bad-write.c │ │ │ ├── bad-write.ck │ │ │ ├── bad-write2.c │ │ │ ├── bad-write2.ck │ │ │ ├── boundary.c │ │ │ ├── boundary.h │ │ │ ├── child-bad.c │ │ │ ├── child-close.c │ │ │ ├── child-rox.c │ │ │ ├── child-simple.c │ │ │ ├── close-bad-fd.c │ │ │ ├── close-bad-fd.ck │ │ │ ├── close-normal.c │ │ │ ├── close-normal.ck │ │ │ ├── close-stdin.c │ │ │ ├── close-stdin.ck │ │ │ ├── close-stdout.c │ │ │ ├── close-stdout.ck │ │ │ ├── close-twice.c │ │ │ ├── close-twice.ck │ │ │ ├── create-bad-ptr.c │ │ │ ├── create-bad-ptr.ck │ │ │ ├── create-bound.c │ │ │ ├── create-bound.ck │ │ │ ├── create-empty.c │ │ │ ├── create-empty.ck │ │ │ ├── create-exists.c │ │ │ ├── create-exists.ck │ │ │ ├── create-long.c │ │ │ ├── create-long.ck │ │ │ ├── create-normal.c │ │ │ ├── create-normal.ck │ │ │ ├── create-null.c │ │ │ ├── create-null.ck │ │ │ ├── exec-arg.c │ │ │ ├── exec-arg.ck │ │ │ ├── exec-bad-ptr.c │ │ │ ├── exec-bad-ptr.ck │ │ │ ├── exec-missing.c │ │ │ ├── exec-missing.ck │ │ │ ├── exec-multiple.c │ │ │ ├── exec-multiple.ck │ │ │ ├── exec-once.c │ │ │ ├── exec-once.ck │ │ │ ├── exit.c │ │ │ ├── exit.ck │ │ │ ├── filesize.c │ │ │ ├── filesize.ck │ │ │ ├── halt.c │ │ │ ├── halt.ck │ │ │ ├── iloveos.c │ │ │ ├── iloveos.ck │ │ │ ├── lib │ │ │ │ ├── .gitignore │ │ │ │ └── user │ │ │ │ │ ├── .dummy │ │ │ │ │ └── .gitignore │ │ │ ├── multi-child-fd.c │ │ │ ├── multi-child-fd.ck │ │ │ ├── multi-recurse.c │ │ │ ├── multi-recurse.ck │ │ │ ├── no-vm │ │ │ │ ├── Make.tests │ │ │ │ ├── Rubric │ │ │ │ ├── multi-oom.c │ │ │ │ └── multi-oom.ck │ │ │ ├── open-bad-ptr.c │ │ │ ├── open-bad-ptr.ck │ │ │ ├── open-boundary.c │ │ │ ├── open-boundary.ck │ │ │ ├── open-empty.c │ │ │ ├── open-empty.ck │ │ │ ├── open-missing.c │ │ │ ├── open-missing.ck │ │ │ ├── open-normal.c │ │ │ ├── open-normal.ck │ │ │ ├── open-null.c │ │ │ ├── open-null.ck │ │ │ ├── open-twice.c │ │ │ ├── open-twice.ck │ │ │ ├── practice.c │ │ │ ├── practice.ck │ │ │ ├── read-bad-fd.c │ │ │ ├── read-bad-fd.ck │ │ │ ├── read-bad-ptr.c │ │ │ ├── read-bad-ptr.ck │ │ │ ├── read-boundary.c │ │ │ ├── read-boundary.ck │ │ │ ├── read-normal.c │ │ │ ├── read-normal.ck │ │ │ ├── read-stdout.c │ │ │ ├── read-stdout.ck │ │ │ ├── read-zero.c │ │ │ ├── read-zero.ck │ │ │ ├── rox-child.c │ │ │ ├── rox-child.ck │ │ │ ├── rox-child.inc │ │ │ ├── rox-multichild.c │ │ │ ├── rox-multichild.ck │ │ │ ├── rox-simple.c │ │ │ ├── rox-simple.ck │ │ │ ├── sample.inc │ │ │ ├── sample.txt │ │ │ ├── sc-bad-arg.c │ │ │ ├── sc-bad-arg.ck │ │ │ ├── sc-bad-sp.c │ │ │ ├── sc-bad-sp.ck │ │ │ ├── sc-boundary-2.c │ │ │ ├── sc-boundary-2.ck │ │ │ ├── sc-boundary.c │ │ │ ├── sc-boundary.ck │ │ │ ├── seek-tell.c │ │ │ ├── seek-tell.ck │ │ │ ├── wait-bad-pid.c │ │ │ ├── wait-bad-pid.ck │ │ │ ├── wait-killed.c │ │ │ ├── wait-killed.ck │ │ │ ├── wait-simple.c │ │ │ ├── wait-simple.ck │ │ │ ├── wait-twice.c │ │ │ ├── wait-twice.ck │ │ │ ├── write-bad-fd.c │ │ │ ├── write-bad-fd.ck │ │ │ ├── write-bad-ptr.c │ │ │ ├── write-bad-ptr.ck │ │ │ ├── write-boundary.c │ │ │ ├── write-boundary.ck │ │ │ ├── write-normal.c │ │ │ ├── write-normal.ck │ │ │ ├── write-stdin.c │ │ │ ├── write-stdin.ck │ │ │ ├── write-zero.c │ │ │ └── write-zero.ck │ │ └── vm │ │ │ ├── Grading │ │ │ ├── Make.tests │ │ │ ├── Rubric.functionality │ │ │ ├── Rubric.robustness │ │ │ ├── child-inherit.c │ │ │ ├── child-linear.c │ │ │ ├── child-mm-wrt.c │ │ │ ├── child-qsort-mm.c │ │ │ ├── child-qsort.c │ │ │ ├── child-sort.c │ │ │ ├── mmap-bad-fd.c │ │ │ ├── mmap-bad-fd.ck │ │ │ ├── mmap-clean.c │ │ │ ├── mmap-clean.ck │ │ │ ├── mmap-close.c │ │ │ ├── mmap-close.ck │ │ │ ├── mmap-exit.c │ │ │ ├── mmap-exit.ck │ │ │ ├── mmap-inherit.c │ │ │ ├── mmap-inherit.ck │ │ │ ├── mmap-misalign.c │ │ │ ├── mmap-misalign.ck │ │ │ ├── mmap-null.c │ │ │ ├── mmap-null.ck │ │ │ ├── mmap-over-code.c │ │ │ ├── mmap-over-code.ck │ │ │ ├── mmap-over-data.c │ │ │ ├── mmap-over-data.ck │ │ │ ├── mmap-over-stk.c │ │ │ ├── mmap-over-stk.ck │ │ │ ├── mmap-overlap.c │ │ │ ├── mmap-overlap.ck │ │ │ ├── mmap-read.c │ │ │ ├── mmap-read.ck │ │ │ ├── mmap-remove.c │ │ │ ├── mmap-remove.ck │ │ │ ├── mmap-shuffle.c │ │ │ ├── mmap-shuffle.ck │ │ │ ├── mmap-twice.c │ │ │ ├── mmap-twice.ck │ │ │ ├── mmap-unmap.c │ │ │ ├── mmap-unmap.ck │ │ │ ├── mmap-write.c │ │ │ ├── mmap-write.ck │ │ │ ├── mmap-zero.c │ │ │ ├── mmap-zero.ck │ │ │ ├── page-linear.c │ │ │ ├── page-linear.ck │ │ │ ├── page-merge-mm.c │ │ │ ├── page-merge-mm.ck │ │ │ ├── page-merge-par.c │ │ │ ├── page-merge-par.ck │ │ │ ├── page-merge-seq.c │ │ │ ├── page-merge-seq.ck │ │ │ ├── page-merge-stk.c │ │ │ ├── page-merge-stk.ck │ │ │ ├── page-parallel.c │ │ │ ├── page-parallel.ck │ │ │ ├── page-shuffle.c │ │ │ ├── page-shuffle.ck │ │ │ ├── parallel-merge.c │ │ │ ├── parallel-merge.h │ │ │ ├── process_death.pm │ │ │ ├── pt-bad-addr.c │ │ │ ├── pt-bad-addr.ck │ │ │ ├── pt-bad-read.c │ │ │ ├── pt-bad-read.ck │ │ │ ├── pt-big-stk-obj.c │ │ │ ├── pt-big-stk-obj.ck │ │ │ ├── pt-grow-bad.c │ │ │ ├── pt-grow-bad.ck │ │ │ ├── pt-grow-pusha.c │ │ │ ├── pt-grow-pusha.ck │ │ │ ├── pt-grow-stack.c │ │ │ ├── pt-grow-stack.ck │ │ │ ├── pt-grow-stk-sc.c │ │ │ ├── pt-grow-stk-sc.ck │ │ │ ├── pt-write-code-2.c │ │ │ ├── pt-write-code.c │ │ │ ├── pt-write-code.ck │ │ │ ├── pt-write-code2.ck │ │ │ ├── qsort.c │ │ │ ├── qsort.h │ │ │ ├── sample.inc │ │ │ └── sample.txt │ ├── threads │ │ ├── .gitignore │ │ ├── Make.vars │ │ ├── Makefile │ │ ├── fixed-point.h │ │ ├── flags.h │ │ ├── init.c │ │ ├── init.h │ │ ├── interrupt.c │ │ ├── interrupt.h │ │ ├── intr-stubs.S │ │ ├── intr-stubs.h │ │ ├── io.h │ │ ├── kernel.lds.S │ │ ├── loader.S │ │ ├── loader.h │ │ ├── malloc.c │ │ ├── malloc.h │ │ ├── palloc.c │ │ ├── palloc.h │ │ ├── pte.h │ │ ├── start.S │ │ ├── switch.S │ │ ├── switch.h │ │ ├── synch.c │ │ ├── synch.h │ │ ├── thread.c │ │ ├── thread.h │ │ └── vaddr.h │ ├── userprog │ │ ├── .gitignore │ │ ├── Make.vars │ │ ├── Makefile │ │ ├── exception.c │ │ ├── exception.h │ │ ├── gdt.c │ │ ├── gdt.h │ │ ├── pagedir.c │ │ ├── pagedir.h │ │ ├── process.c │ │ ├── process.h │ │ ├── syscall.c │ │ ├── syscall.h │ │ ├── tss.c │ │ └── tss.h │ ├── utils │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── Pintos.pm │ │ ├── backtrace │ │ ├── pintos │ │ ├── pintos-gdb │ │ ├── pintos-mkdisk │ │ ├── pintos-set-cmdline │ │ ├── setitimer-helper.c │ │ ├── squish-pty.c │ │ └── squish-unix.c │ └── vm │ │ ├── .gitignore │ │ ├── Make.vars │ │ └── Makefile └── utils │ └── run.sh └── reports ├── project1.md ├── project2.md └── project3.md /README.md: -------------------------------------------------------------------------------- 1 | CS162 Group Repository 2 | ====================== 3 | 4 | This repository contains code for CS162 group projects. 5 | 6 | **Design documents** 7 | 8 | * [Project 1: Threads](doc/project1.md) 9 | * [Project 2: User Programs](doc/project2.md) 10 | * [Project 3: File System](doc/project3.md) 11 | 12 | **Final reports** 13 | 14 | * [Project 1: Threads](reports/project1.md) 15 | * [Project 2: User Programs](reports/project2.md) 16 | * [Project 3: File System](reports/project3.md) 17 | -------------------------------------------------------------------------------- /pintos/._.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jangsoo/PintosOS/0cfab4a123a9e8a21a102e4da11916ff61d12df0/pintos/._.DS_Store -------------------------------------------------------------------------------- /pintos/src/._.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jangsoo/PintosOS/0cfab4a123a9e8a21a102e4da11916ff61d12df0/pintos/src/._.DS_Store -------------------------------------------------------------------------------- /pintos/src/.gitignore: -------------------------------------------------------------------------------- 1 | cscope.files 2 | cscope.out 3 | TAGS 4 | tags 5 | -------------------------------------------------------------------------------- /pintos/src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_SUBDIRS = threads userprog vm filesys 2 | 3 | all:: 4 | @echo "Run 'make' in subdirectories: $(BUILD_SUBDIRS)." 5 | @echo "This top-level make has only 'clean' targets." 6 | 7 | CLEAN_SUBDIRS = $(BUILD_SUBDIRS) examples utils 8 | 9 | clean:: 10 | for d in $(CLEAN_SUBDIRS); do $(MAKE) -C $$d $@; done 11 | rm -f TAGS tags 12 | 13 | distclean:: clean 14 | find . -name '*~' -exec rm '{}' \; 15 | 16 | TAGS_SUBDIRS = $(BUILD_SUBDIRS) devices lib 17 | TAGS_SOURCES = find $(TAGS_SUBDIRS) -name \*.[chS] -print 18 | 19 | TAGS:: 20 | etags --members `$(TAGS_SOURCES)` 21 | 22 | tags:: 23 | ctags -T --no-warn `$(TAGS_SOURCES)` 24 | 25 | cscope.files:: 26 | $(TAGS_SOURCES) > cscope.files 27 | 28 | cscope:: cscope.files 29 | cscope -b -q -k 30 | -------------------------------------------------------------------------------- /pintos/src/Makefile.kernel: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | all: 4 | 5 | include Make.vars 6 | 7 | DIRS = $(sort $(addprefix build/,$(KERNEL_SUBDIRS) $(TEST_SUBDIRS) lib/user)) 8 | 9 | all grade check: $(DIRS) build/Makefile 10 | cd build && $(MAKE) $@ 11 | $(DIRS): 12 | mkdir -p $@ 13 | build/Makefile: ../Makefile.build 14 | cp $< $@ 15 | 16 | build/%: $(DIRS) build/Makefile 17 | cd build && $(MAKE) $* 18 | 19 | clean: 20 | rm -rf build 21 | -------------------------------------------------------------------------------- /pintos/src/devices/ide.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_IDE_H 2 | #define DEVICES_IDE_H 3 | 4 | void ide_init (void); 5 | 6 | #endif /* devices/ide.h */ 7 | -------------------------------------------------------------------------------- /pintos/src/devices/input.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_INPUT_H 2 | #define DEVICES_INPUT_H 3 | 4 | #include 5 | #include 6 | 7 | void input_init (void); 8 | void input_putc (uint8_t); 9 | uint8_t input_getc (void); 10 | bool input_full (void); 11 | 12 | #endif /* devices/input.h */ 13 | -------------------------------------------------------------------------------- /pintos/src/devices/kbd.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_KBD_H 2 | #define DEVICES_KBD_H 3 | 4 | #include 5 | 6 | void kbd_init (void); 7 | void kbd_print_stats (void); 8 | 9 | #endif /* devices/kbd.h */ 10 | -------------------------------------------------------------------------------- /pintos/src/devices/partition.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_PARTITION_H 2 | #define DEVICES_PARTITION_H 3 | 4 | struct block; 5 | 6 | void partition_scan (struct block *); 7 | 8 | #endif /* devices/partition.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/devices/pit.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_PIT_H 2 | #define DEVICES_PIT_H 3 | 4 | #include 5 | 6 | void pit_configure_channel (int channel, int mode, int frequency); 7 | 8 | #endif /* devices/pit.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/devices/rtc.h: -------------------------------------------------------------------------------- 1 | #ifndef RTC_H 2 | #define RTC_H 3 | 4 | typedef unsigned long time_t; 5 | 6 | time_t rtc_get_time (void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /pintos/src/devices/serial.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_SERIAL_H 2 | #define DEVICES_SERIAL_H 3 | 4 | #include 5 | 6 | void serial_init_queue (void); 7 | void serial_putc (uint8_t); 8 | void serial_flush (void); 9 | void serial_notify (void); 10 | 11 | #endif /* devices/serial.h */ 12 | -------------------------------------------------------------------------------- /pintos/src/devices/shutdown.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_SHUTDOWN_H 2 | #define DEVICES_SHUTDOWN_H 3 | 4 | #include 5 | 6 | /* How to shut down when Pintos has nothing left to do. */ 7 | enum shutdown_type 8 | { 9 | SHUTDOWN_NONE, /* Loop forever. */ 10 | SHUTDOWN_POWER_OFF, /* Power off the machine (if possible). */ 11 | SHUTDOWN_REBOOT, /* Reboot the machine (if possible). */ 12 | }; 13 | 14 | void shutdown (void); 15 | void shutdown_configure (enum shutdown_type); 16 | void shutdown_reboot (void) NO_RETURN; 17 | void shutdown_power_off (void) NO_RETURN; 18 | 19 | #endif /* devices/shutdown.h */ 20 | -------------------------------------------------------------------------------- /pintos/src/devices/speaker.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_SPEAKER_H 2 | #define DEVICES_SPEAKER_H 3 | 4 | void speaker_on (int frequency); 5 | void speaker_off (void); 6 | void speaker_beep (void); 7 | 8 | #endif /* devices/speaker.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/devices/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_TIMER_H 2 | #define DEVICES_TIMER_H 3 | 4 | #include 5 | #include 6 | 7 | /* Number of timer interrupts per second. */ 8 | #define TIMER_FREQ 100 9 | 10 | void timer_init (void); 11 | void timer_calibrate (void); 12 | 13 | int64_t timer_ticks (void); 14 | int64_t timer_elapsed (int64_t); 15 | 16 | /* Sleep and yield the CPU to other threads. */ 17 | void timer_sleep (int64_t ticks); 18 | void timer_msleep (int64_t milliseconds); 19 | void timer_usleep (int64_t microseconds); 20 | void timer_nsleep (int64_t nanoseconds); 21 | 22 | /* Busy waits. */ 23 | void timer_mdelay (int64_t milliseconds); 24 | void timer_udelay (int64_t microseconds); 25 | void timer_ndelay (int64_t nanoseconds); 26 | 27 | void timer_print_stats (void); 28 | 29 | #endif /* devices/timer.h */ 30 | -------------------------------------------------------------------------------- /pintos/src/devices/vga.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_VGA_H 2 | #define DEVICES_VGA_H 3 | 4 | void vga_putc (int); 5 | 6 | #endif /* devices/vga.h */ 7 | -------------------------------------------------------------------------------- /pintos/src/examples/.gitignore: -------------------------------------------------------------------------------- 1 | cat 2 | cmp 3 | cp 4 | echo 5 | halt 6 | hex-dump 7 | ls 8 | mcat 9 | mcp 10 | mkdir 11 | pwd 12 | rm 13 | shell 14 | bubsort 15 | insult 16 | lineup 17 | matmult 18 | recursor 19 | *.d 20 | -------------------------------------------------------------------------------- /pintos/src/examples/cat.c: -------------------------------------------------------------------------------- 1 | /* cat.c 2 | 3 | Prints files specified on command line to the console. */ 4 | 5 | #include 6 | #include 7 | 8 | int 9 | main (int argc, char *argv[]) 10 | { 11 | bool success = true; 12 | int i; 13 | 14 | for (i = 1; i < argc; i++) 15 | { 16 | int fd = open (argv[i]); 17 | if (fd < 0) 18 | { 19 | printf ("%s: open failed\n", argv[i]); 20 | success = false; 21 | continue; 22 | } 23 | for (;;) 24 | { 25 | char buffer[1024]; 26 | int bytes_read = read (fd, buffer, sizeof buffer); 27 | if (bytes_read == 0) 28 | break; 29 | write (STDOUT_FILENO, buffer, bytes_read); 30 | } 31 | close (fd); 32 | } 33 | return success ? EXIT_SUCCESS : EXIT_FAILURE; 34 | } 35 | -------------------------------------------------------------------------------- /pintos/src/examples/echo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int 5 | main (int argc, char **argv) 6 | { 7 | int i; 8 | 9 | for (i = 0; i < argc; i++) 10 | printf ("%s ", argv[i]); 11 | printf ("\n"); 12 | 13 | return EXIT_SUCCESS; 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/examples/halt.c: -------------------------------------------------------------------------------- 1 | /* halt.c 2 | 3 | Simple program to test whether running a user program works. 4 | 5 | Just invokes a system call that shuts down the OS. */ 6 | 7 | #include 8 | 9 | int 10 | main (void) 11 | { 12 | halt (); 13 | /* not reached */ 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/examples/hex-dump.c: -------------------------------------------------------------------------------- 1 | /* hex-dump.c 2 | 3 | Prints files specified on command line to the console in hex. */ 4 | 5 | #include 6 | #include 7 | 8 | int 9 | main (int argc, char *argv[]) 10 | { 11 | bool success = true; 12 | int i; 13 | 14 | for (i = 1; i < argc; i++) 15 | { 16 | int fd = open (argv[i]); 17 | if (fd < 0) 18 | { 19 | printf ("%s: open failed\n", argv[i]); 20 | success = false; 21 | continue; 22 | } 23 | for (;;) 24 | { 25 | char buffer[1024]; 26 | int pos = tell (fd); 27 | int bytes_read = read (fd, buffer, sizeof buffer); 28 | if (bytes_read == 0) 29 | break; 30 | hex_dump (pos, buffer, bytes_read, true); 31 | } 32 | close (fd); 33 | } 34 | return success ? EXIT_SUCCESS : EXIT_FAILURE; 35 | } 36 | -------------------------------------------------------------------------------- /pintos/src/examples/lib/.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | -------------------------------------------------------------------------------- /pintos/src/examples/lib/user/.dummy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jangsoo/PintosOS/0cfab4a123a9e8a21a102e4da11916ff61d12df0/pintos/src/examples/lib/user/.dummy -------------------------------------------------------------------------------- /pintos/src/examples/lib/user/.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | -------------------------------------------------------------------------------- /pintos/src/examples/mkdir.c: -------------------------------------------------------------------------------- 1 | /* mkdir.c 2 | 3 | Creates a directory. */ 4 | 5 | #include 6 | #include 7 | 8 | int 9 | main (int argc, char *argv[]) 10 | { 11 | if (argc != 2) 12 | { 13 | printf ("usage: %s DIRECTORY\n", argv[0]); 14 | return EXIT_FAILURE; 15 | } 16 | 17 | if (!mkdir (argv[1])) 18 | { 19 | printf ("%s: mkdir failed\n", argv[1]); 20 | return EXIT_FAILURE; 21 | } 22 | 23 | return EXIT_SUCCESS; 24 | } 25 | -------------------------------------------------------------------------------- /pintos/src/examples/recursor.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | main (int argc, char *argv[]) 7 | { 8 | char buffer[128]; 9 | pid_t pid; 10 | int retval = 0; 11 | 12 | if (argc != 4) 13 | { 14 | printf ("usage: recursor \n"); 15 | exit (1); 16 | } 17 | 18 | /* Print args. */ 19 | printf ("%s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]); 20 | 21 | /* Execute child and wait for it to finish if requested. */ 22 | if (atoi (argv[2]) != 0) 23 | { 24 | snprintf (buffer, sizeof buffer, 25 | "recursor %s %d %s", argv[1], atoi (argv[2]) - 1, argv[3]); 26 | pid = exec (buffer); 27 | if (atoi (argv[3])) 28 | retval = wait (pid); 29 | } 30 | 31 | /* Done. */ 32 | printf ("%s %s: dying, retval=%d\n", argv[1], argv[2], retval); 33 | exit (retval); 34 | } 35 | -------------------------------------------------------------------------------- /pintos/src/examples/rm.c: -------------------------------------------------------------------------------- 1 | /* rm.c 2 | 3 | Removes files specified on command line. */ 4 | 5 | #include 6 | #include 7 | 8 | int 9 | main (int argc, char *argv[]) 10 | { 11 | bool success = true; 12 | int i; 13 | 14 | for (i = 1; i < argc; i++) 15 | if (!remove (argv[i])) 16 | { 17 | printf ("%s: remove failed\n", argv[i]); 18 | success = false; 19 | } 20 | return success ? EXIT_SUCCESS : EXIT_FAILURE; 21 | } 22 | -------------------------------------------------------------------------------- /pintos/src/filesys/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | bochsrc.txt 3 | bochsout.txt 4 | -------------------------------------------------------------------------------- /pintos/src/filesys/Make.vars: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | kernel.bin: DEFINES = -DUSERPROG -DFILESYS 4 | KERNEL_SUBDIRS = threads devices lib lib/kernel userprog filesys 5 | TEST_SUBDIRS = tests/userprog tests/filesys/base tests/filesys/extended 6 | GRADING_FILE = $(SRCDIR)/tests/filesys/Grading.no-vm 7 | SIMULATOR = --qemu 8 | 9 | # Uncomment the lines below to enable VM. 10 | #kernel.bin: DEFINES += -DVM 11 | #KERNEL_SUBDIRS += vm 12 | #TEST_SUBDIRS += tests/vm 13 | #GRADING_FILE = $(SRCDIR)/tests/filesys/Grading.with-vm 14 | -------------------------------------------------------------------------------- /pintos/src/filesys/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.kernel 2 | -------------------------------------------------------------------------------- /pintos/src/filesys/file.h: -------------------------------------------------------------------------------- 1 | #ifndef FILESYS_FILE_H 2 | #define FILESYS_FILE_H 3 | 4 | #include "filesys/off_t.h" 5 | 6 | struct inode; 7 | 8 | /* Opening and closing files. */ 9 | struct file *file_open (struct inode *); 10 | struct file *file_reopen (struct file *); 11 | void file_close (struct file *); 12 | struct inode *file_get_inode (struct file *); 13 | 14 | /* Reading and writing. */ 15 | off_t file_read (struct file *, void *, off_t); 16 | off_t file_read_at (struct file *, void *, off_t size, off_t start); 17 | off_t file_write (struct file *, const void *, off_t); 18 | off_t file_write_at (struct file *, const void *, off_t size, off_t start); 19 | 20 | /* Preventing writes. */ 21 | void file_deny_write (struct file *); 22 | void file_allow_write (struct file *); 23 | 24 | /* File position. */ 25 | void file_seek (struct file *, off_t); 26 | off_t file_tell (struct file *); 27 | off_t file_length (struct file *); 28 | 29 | #endif /* filesys/file.h */ 30 | -------------------------------------------------------------------------------- /pintos/src/filesys/filesys.h: -------------------------------------------------------------------------------- 1 | #ifndef FILESYS_FILESYS_H 2 | #define FILESYS_FILESYS_H 3 | 4 | #include 5 | #include "filesys/off_t.h" 6 | 7 | /* Sectors of system file inodes. */ 8 | #define FREE_MAP_SECTOR 0 /* Free map file inode sector. */ 9 | #define ROOT_DIR_SECTOR 1 /* Root directory file inode sector. */ 10 | 11 | /* Block device that contains the file system. */ 12 | struct block *fs_device; 13 | 14 | void filesys_init (bool format); 15 | void filesys_done (void); 16 | bool filesys_create (const char *name, off_t initial_size, bool is_dir); 17 | struct file *filesys_open (const char *name); 18 | bool filesys_remove (const char *name); 19 | 20 | struct dir* traverse(const char* name, char** last_name); 21 | 22 | #endif /* filesys/filesys.h */ 23 | -------------------------------------------------------------------------------- /pintos/src/filesys/free-map.h: -------------------------------------------------------------------------------- 1 | #ifndef FILESYS_FREE_MAP_H 2 | #define FILESYS_FREE_MAP_H 3 | 4 | #include 5 | #include 6 | #include "devices/block.h" 7 | 8 | void free_map_init (void); 9 | void free_map_read (void); 10 | void free_map_create (void); 11 | void free_map_open (void); 12 | void free_map_close (void); 13 | 14 | uint32_t free_map_num_free(void); 15 | 16 | bool free_map_allocate (size_t, block_sector_t *); 17 | void free_map_release (block_sector_t, size_t); 18 | 19 | struct lock free_map_lock; /* Free map lock */ 20 | uint32_t num_free; /* Free map number free */ 21 | 22 | #endif /* filesys/free-map.h */ 23 | -------------------------------------------------------------------------------- /pintos/src/filesys/fsutil.h: -------------------------------------------------------------------------------- 1 | #ifndef FILESYS_FSUTIL_H 2 | #define FILESYS_FSUTIL_H 3 | 4 | void fsutil_ls (char **argv); 5 | void fsutil_cat (char **argv); 6 | void fsutil_rm (char **argv); 7 | void fsutil_extract (char **argv); 8 | void fsutil_append (char **argv); 9 | 10 | #endif /* filesys/fsutil.h */ 11 | -------------------------------------------------------------------------------- /pintos/src/filesys/off_t.h: -------------------------------------------------------------------------------- 1 | #ifndef FILESYS_OFF_T_H 2 | #define FILESYS_OFF_T_H 3 | 4 | #include 5 | 6 | /* An offset within a file. 7 | This is a separate header because multiple headers want this 8 | definition but not any others. */ 9 | typedef int32_t off_t; 10 | 11 | /* Format specifier for printf(), e.g.: 12 | printf ("offset=%"PROTd"\n", offset); */ 13 | #define PROTd PRId32 14 | 15 | #endif /* filesys/off_t.h */ 16 | -------------------------------------------------------------------------------- /pintos/src/filesys/testfiles/test-buffer-write-full-blocks-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"testme" => [random_bytes (102400)]}); 7 | pass; 8 | -------------------------------------------------------------------------------- /pintos/src/filesys/testfiles/test-cache-improvement-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"please" => [random_bytes (2048)]}); 7 | pass; 8 | -------------------------------------------------------------------------------- /pintos/src/lib/kernel/console.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_KERNEL_CONSOLE_H 2 | #define __LIB_KERNEL_CONSOLE_H 3 | 4 | void console_init (void); 5 | void console_panic (void); 6 | void console_print_stats (void); 7 | 8 | #endif /* lib/kernel/console.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/lib/kernel/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_KERNEL_STDIO_H 2 | #define __LIB_KERNEL_STDIO_H 3 | 4 | void putbuf (const char *, size_t); 5 | 6 | #endif /* lib/kernel/stdio.h */ 7 | -------------------------------------------------------------------------------- /pintos/src/lib/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_LIMITS_H 2 | #define __LIB_LIMITS_H 3 | 4 | #define CHAR_BIT 8 5 | 6 | #define SCHAR_MAX 127 7 | #define SCHAR_MIN (-SCHAR_MAX - 1) 8 | #define UCHAR_MAX 255 9 | 10 | #ifdef __CHAR_UNSIGNED__ 11 | #define CHAR_MIN 0 12 | #define CHAR_MAX UCHAR_MAX 13 | #else 14 | #define CHAR_MIN SCHAR_MIN 15 | #define CHAR_MAX SCHAR_MAX 16 | #endif 17 | 18 | #define SHRT_MAX 32767 19 | #define SHRT_MIN (-SHRT_MAX - 1) 20 | #define USHRT_MAX 65535 21 | 22 | #define INT_MAX 2147483647 23 | #define INT_MIN (-INT_MAX - 1) 24 | #define UINT_MAX 4294967295U 25 | 26 | #define LONG_MAX 2147483647L 27 | #define LONG_MIN (-LONG_MAX - 1) 28 | #define ULONG_MAX 4294967295UL 29 | 30 | #define LLONG_MAX 9223372036854775807LL 31 | #define LLONG_MIN (-LLONG_MAX - 1) 32 | #define ULLONG_MAX 18446744073709551615ULL 33 | 34 | #endif /* lib/limits.h */ 35 | -------------------------------------------------------------------------------- /pintos/src/lib/packed.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_PACKED_H 2 | #define __LIB_PACKED_H 3 | 4 | /* The "packed" attribute, when applied to a structure, prevents 5 | GCC from inserting padding bytes between or after structure 6 | members. It must be specified at the time of the structure's 7 | definition, normally just after the closing brace. */ 8 | #define PACKED __attribute__ ((packed)) 9 | 10 | #endif /* lib/packed.h */ 11 | -------------------------------------------------------------------------------- /pintos/src/lib/random.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_RANDOM_H 2 | #define __LIB_RANDOM_H 3 | 4 | #include 5 | 6 | void random_init (unsigned seed); 7 | void random_bytes (void *, size_t); 8 | unsigned long random_ulong (void); 9 | 10 | #endif /* lib/random.h */ 11 | -------------------------------------------------------------------------------- /pintos/src/lib/round.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_ROUND_H 2 | #define __LIB_ROUND_H 3 | 4 | /* Yields X rounded up to the nearest multiple of STEP. 5 | For X >= 0, STEP >= 1 only. */ 6 | #define ROUND_UP(X, STEP) (((X) + (STEP) - 1) / (STEP) * (STEP)) 7 | 8 | /* Yields X divided by STEP, rounded up. 9 | For X >= 0, STEP >= 1 only. */ 10 | #define DIV_ROUND_UP(X, STEP) (((X) + (STEP) - 1) / (STEP)) 11 | 12 | /* Yields X rounded down to the nearest multiple of STEP. 13 | For X >= 0, STEP >= 1 only. */ 14 | #define ROUND_DOWN(X, STEP) ((X) / (STEP) * (STEP)) 15 | 16 | /* There is no DIV_ROUND_DOWN. It would be simply X / STEP. */ 17 | 18 | #endif /* lib/round.h */ 19 | -------------------------------------------------------------------------------- /pintos/src/lib/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_STDARG_H 2 | #define __LIB_STDARG_H 3 | 4 | /* GCC has functionality as built-ins, 5 | so all we need is to use it. */ 6 | 7 | typedef __builtin_va_list va_list; 8 | 9 | #define va_start(LIST, ARG) __builtin_va_start (LIST, ARG) 10 | #define va_end(LIST) __builtin_va_end (LIST) 11 | #define va_arg(LIST, TYPE) __builtin_va_arg (LIST, TYPE) 12 | #define va_copy(DST, SRC) __builtin_va_copy (DST, SRC) 13 | 14 | #endif /* lib/stdarg.h */ 15 | -------------------------------------------------------------------------------- /pintos/src/lib/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_STDBOOL_H 2 | #define __LIB_STDBOOL_H 3 | 4 | #define bool _Bool 5 | #define true 1 6 | #define false 0 7 | #define __bool_true_false_are_defined 1 8 | 9 | #endif /* lib/stdbool.h */ 10 | -------------------------------------------------------------------------------- /pintos/src/lib/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_STDDEF_H 2 | #define __LIB_STDDEF_H 3 | 4 | #define NULL ((void *) 0) 5 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER) 6 | 7 | /* GCC predefines the types we need for ptrdiff_t and size_t, 8 | so that we don't have to guess. */ 9 | typedef __PTRDIFF_TYPE__ ptrdiff_t; 10 | typedef __SIZE_TYPE__ size_t; 11 | 12 | #endif /* lib/stddef.h */ 13 | -------------------------------------------------------------------------------- /pintos/src/lib/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_STDLIB_H 2 | #define __LIB_STDLIB_H 3 | 4 | #include 5 | 6 | /* Standard functions. */ 7 | int atoi (const char *); 8 | void qsort (void *array, size_t cnt, size_t size, 9 | int (*compare) (const void *, const void *)); 10 | void *bsearch (const void *key, const void *array, size_t cnt, 11 | size_t size, int (*compare) (const void *, const void *)); 12 | 13 | /* Nonstandard functions. */ 14 | void sort (void *array, size_t cnt, size_t size, 15 | int (*compare) (const void *, const void *, void *aux), 16 | void *aux); 17 | void *binary_search (const void *key, const void *array, size_t cnt, 18 | size_t size, 19 | int (*compare) (const void *, const void *, void *aux), 20 | void *aux); 21 | 22 | #endif /* lib/stdlib.h */ 23 | -------------------------------------------------------------------------------- /pintos/src/lib/user/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /* Aborts the user program, printing the source file name, line 8 | number, and function name, plus a user-specific message. */ 9 | void 10 | debug_panic (const char *file, int line, const char *function, 11 | const char *message, ...) 12 | { 13 | va_list args; 14 | 15 | printf ("User process ABORT at %s:%d in %s(): ", file, line, function); 16 | 17 | va_start (args, message); 18 | vprintf (message, args); 19 | printf ("\n"); 20 | va_end (args); 21 | 22 | debug_backtrace (); 23 | 24 | exit (1); 25 | } 26 | -------------------------------------------------------------------------------- /pintos/src/lib/user/entry.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main (int, char *[]); 4 | void _start (int argc, char *argv[]); 5 | 6 | void 7 | _start (int argc, char *argv[]) 8 | { 9 | exit (main (argc, argv)); 10 | } 11 | -------------------------------------------------------------------------------- /pintos/src/lib/user/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef __LIB_USER_STDIO_H 2 | #define __LIB_USER_STDIO_H 3 | 4 | int hprintf (int, const char *, ...) PRINTF_FORMAT (2, 3); 5 | int vhprintf (int, const char *, va_list) PRINTF_FORMAT (2, 0); 6 | 7 | #endif /* lib/user/stdio.h */ 8 | -------------------------------------------------------------------------------- /pintos/src/misc/bochs-2.2.6-ms-extensions.patch: -------------------------------------------------------------------------------- 1 | diff -urp orig/bochs-2.1.1/gui/Makefile.in bochs-2.1.1/gui/Makefile.in 2 | --- orig/bochs-2.1.1/gui/Makefile.in 2003-11-28 07:07:28.000000000 -0800 3 | +++ bochs-2.1.1/gui/Makefile.in 2004-09-13 15:05:09.402039000 -0700 4 | @@ -44,7 +44,7 @@ SHELL = /bin/sh 5 | @SET_MAKE@ 6 | 7 | CXX = @CXX@ 8 | -CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@ @GUI_CXXFLAGS@ 9 | +CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@ @GUI_CXXFLAGS@ -fms-extensions 10 | LOCAL_CXXFLAGS = 11 | LDFLAGS = @LDFLAGS@ 12 | LIBS = @LIBS@ 13 | 14 | 15 | -------------------------------------------------------------------------------- /pintos/src/misc/bochs-2.2.6-namespace.patch: -------------------------------------------------------------------------------- 1 | --- bochs-2.2.6/bx_debug/symbols.cc 2011-08-19 11:04:11.760139836 -0600 2 | +++ bochs-2.2.6-patched/bx_debug/symbols.cc 2011-08-19 11:04:04.980139837 -0600 3 | @@ -92,6 +92,7 @@ 4 | #endif 5 | 6 | using namespace std; 7 | +namespace std { using namespace __gnu_cxx; } 8 | 9 | struct symbol_entry_t 10 | { 11 | -------------------------------------------------------------------------------- /pintos/src/misc/bochs-2.2.6-paranoia.patch: -------------------------------------------------------------------------------- 1 | Index: bochs-2.2.6/iodev/hdimage.h 2 | diff -u bochs-2.2.6/iodev/hdimage.h\~ bochs-2.2.6/iodev/hdimage.h 3 | --- bochs-2.2.6/iodev/hdimage.h~ 2005-11-06 03:07:01.000000000 -0800 4 | +++ bochs-2.2.6/iodev/hdimage.h 2006-09-28 15:55:50.000000000 -0700 5 | @@ -273,14 +273,8 @@ class sparse_image_t : public device_ima 6 | 7 | void panic(const char * message); 8 | off_t 9 | -#ifndef PARANOID 10 | - sparse_image_t:: 11 | -#endif 12 | get_physical_offset(); 13 | void 14 | -#ifndef PARANOID 15 | - sparse_image_t:: 16 | -#endif 17 | set_virtual_page(Bit32u new_virtual_page); 18 | void read_header(); 19 | ssize_t read_page_fragment(Bit32u read_virtual_page, Bit32u read_page_offset, size_t read_size, void * buf); 20 | -------------------------------------------------------------------------------- /pintos/src/misc/bochs-2.2.6-solaris-link.patch: -------------------------------------------------------------------------------- 1 | --- bochs-2.2.6.orig/Makefile.in 2006-04-03 16:34:51.170387000 -0700 2 | +++ bochs-2.2.6/Makefile.in 2006-04-03 16:34:57.480303000 -0700 3 | @@ -93,7 +93,7 @@ 4 | CFLAGS = @CFLAGS@ @GUI_CFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"' 5 | CXXFLAGS = @CXXFLAGS@ @GUI_CXXFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"' 6 | 7 | -LDFLAGS = @LDFLAGS@ 8 | +LDFLAGS = @LDFLAGS@ -lsocket 9 | LIBS = @LIBS@ 10 | # To compile with readline: 11 | # linux needs just -lreadline 12 | -------------------------------------------------------------------------------- /pintos/src/tests/arc4.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_ARC4_H 2 | #define TESTS_ARC4_H 3 | 4 | #include 5 | #include 6 | 7 | /* Alleged RC4 algorithm encryption state. */ 8 | struct arc4 9 | { 10 | uint8_t s[256]; 11 | uint8_t i, j; 12 | }; 13 | 14 | void arc4_init (struct arc4 *, const void *, size_t); 15 | void arc4_crypt (struct arc4 *, void *, size_t); 16 | 17 | #endif /* tests/arc4.h */ 18 | -------------------------------------------------------------------------------- /pintos/src/tests/arc4.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | sub arc4_init { 5 | my ($key) = @_; 6 | my (@s) = 0...255; 7 | my ($j) = 0; 8 | for my $i (0...255) { 9 | $j = ($j + $s[$i] + ord (substr ($key, $i % length ($key), 1))) & 0xff; 10 | @s[$i, $j] = @s[$j, $i]; 11 | } 12 | return (0, 0, @s); 13 | } 14 | 15 | sub arc4_crypt { 16 | my ($arc4, $buf) = @_; 17 | my ($i, $j, @s) = @$arc4; 18 | my ($out) = ""; 19 | for my $c (split (//, $buf)) { 20 | $i = ($i + 1) & 0xff; 21 | $j = ($j + $s[$i]) & 0xff; 22 | @s[$i, $j] = @s[$j, $i]; 23 | $out .= chr (ord ($c) ^ $s[($s[$i] + $s[$j]) & 0xff]); 24 | } 25 | @$arc4 = ($i, $j, @s); 26 | return $out; 27 | } 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /pintos/src/tests/cksum.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_CKSUM_H 2 | #define TESTS_CKSUM_H 3 | 4 | #include 5 | 6 | unsigned long cksum(const void *, size_t); 7 | 8 | #endif /* tests/cksum.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/Grading.no-vm: -------------------------------------------------------------------------------- 1 | # Percentage of the testing point total designated for each set of 2 | # tests. 3 | 4 | # This project is primarily about implementing the file system, but 5 | # all the previous functionality should work too. It's not too easy 6 | # to screw it up, thus the emphasis. 7 | 8 | # 65% for extended file system features. 9 | 30% tests/filesys/extended/Rubric.functionality 10 | 15% tests/filesys/extended/Rubric.robustness 11 | 20% tests/filesys/extended/Rubric.persistence 12 | 13 | # 20% to not break the provided file system features. 14 | 20% tests/filesys/base/Rubric 15 | 16 | # 15% for the rest. 17 | 10% tests/userprog/Rubric.functionality 18 | 5% tests/userprog/Rubric.robustness 19 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/Grading.with-vm: -------------------------------------------------------------------------------- 1 | # Percentage of the testing point total designated for each set of 2 | # tests. 3 | 4 | # This project is primarily about implementing the file system, but 5 | # all the previous functionality should work too. It's not too easy 6 | # to screw it up, thus the emphasis. 7 | 8 | # 65% for extended file system features. 9 | 30% tests/filesys/extended/Rubric.functionality 10 | 15% tests/filesys/extended/Rubric.robustness 11 | 20% tests/filesys/extended/Rubric.persistence 12 | 13 | # 20% to not break the provided file system features. 14 | 20% tests/filesys/base/Rubric 15 | 16 | # 15% for the rest. 17 | 10% tests/userprog/Rubric.functionality 18 | 5% tests/userprog/Rubric.robustness 19 | 20 | # Up to 10% bonus for working VM functionality. 21 | 8% tests/vm/Rubric.functionality 22 | 2% tests/vm/Rubric.robustness 23 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/Make.tests: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | tests/filesys/base_TESTS = $(addprefix tests/filesys/base/,lg-create \ 4 | lg-full lg-random lg-seq-block lg-seq-random sm-create sm-full \ 5 | sm-random sm-seq-block sm-seq-random syn-read syn-remove syn-write) 6 | 7 | tests/filesys/base_PROGS = $(tests/filesys/base_TESTS) $(addprefix \ 8 | tests/filesys/base/,child-syn-read child-syn-wrt) 9 | 10 | $(foreach prog,$(tests/filesys/base_PROGS), \ 11 | $(eval $(prog)_SRC += $(prog).c tests/lib.c tests/filesys/seq-test.c)) 12 | $(foreach prog,$(tests/filesys/base_TESTS), \ 13 | $(eval $(prog)_SRC += tests/main.c)) 14 | 15 | tests/filesys/base/syn-read_PUTFILES = tests/filesys/base/child-syn-read 16 | tests/filesys/base/syn-write_PUTFILES = tests/filesys/base/child-syn-wrt 17 | 18 | tests/filesys/base/syn-read.output: TIMEOUT = 300 19 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/Rubric: -------------------------------------------------------------------------------- 1 | Functionality of base file system: 2 | - Test basic support for small files. 3 | 1 sm-create 4 | 2 sm-full 5 | 2 sm-random 6 | 2 sm-seq-block 7 | 3 sm-seq-random 8 | 9 | - Test basic support for large files. 10 | 1 lg-create 11 | 2 lg-full 12 | 2 lg-random 13 | 2 lg-seq-block 14 | 3 lg-seq-random 15 | 16 | - Test synchronized multiprogram access to files. 17 | 4 syn-read 18 | 4 syn-write 19 | 2 syn-remove 20 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/full.inc: -------------------------------------------------------------------------------- 1 | /* -*- c -*- */ 2 | 3 | #include "tests/filesys/seq-test.h" 4 | #include "tests/main.h" 5 | 6 | static char buf[TEST_SIZE]; 7 | 8 | static size_t 9 | return_test_size (void) 10 | { 11 | return TEST_SIZE; 12 | } 13 | 14 | void 15 | test_main (void) 16 | { 17 | seq_test ("quux", 18 | buf, sizeof buf, sizeof buf, 19 | return_test_size, NULL); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-create.c: -------------------------------------------------------------------------------- 1 | /* Tests that create properly zeros out the contents of a fairly 2 | large file. */ 3 | 4 | #define TEST_SIZE 75678 5 | #include "tests/filesys/create.inc" 6 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-create.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (lg-create) begin 7 | (lg-create) create "blargle" 8 | (lg-create) open "blargle" for verification 9 | (lg-create) verified contents of "blargle" 10 | (lg-create) close "blargle" 11 | (lg-create) end 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-full.c: -------------------------------------------------------------------------------- 1 | /* Writes out the contents of a fairly large file all at once, 2 | and then reads it back to make sure that it was written 3 | properly. */ 4 | 5 | #define TEST_SIZE 75678 6 | #include "tests/filesys/base/full.inc" 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-full.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (lg-full) begin 7 | (lg-full) create "quux" 8 | (lg-full) open "quux" 9 | (lg-full) writing "quux" 10 | (lg-full) close "quux" 11 | (lg-full) open "quux" for verification 12 | (lg-full) verified contents of "quux" 13 | (lg-full) close "quux" 14 | (lg-full) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-random.c: -------------------------------------------------------------------------------- 1 | /* Writes out the content of a fairly large file in random order, 2 | then reads it back in random order to verify that it was 3 | written properly. */ 4 | 5 | #define BLOCK_SIZE 512 6 | #define TEST_SIZE (512 * 150) 7 | #include "tests/filesys/base/random.inc" 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-random.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (lg-random) begin 7 | (lg-random) create "bazzle" 8 | (lg-random) open "bazzle" 9 | (lg-random) write "bazzle" in random order 10 | (lg-random) read "bazzle" in random order 11 | (lg-random) close "bazzle" 12 | (lg-random) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-seq-block.c: -------------------------------------------------------------------------------- 1 | /* Writes out a fairly large file sequentially, one fixed-size 2 | block at a time, then reads it back to verify that it was 3 | written properly. */ 4 | 5 | #define TEST_SIZE 75678 6 | #define BLOCK_SIZE 513 7 | #include "tests/filesys/base/seq-block.inc" 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-seq-block.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (lg-seq-block) begin 7 | (lg-seq-block) create "noodle" 8 | (lg-seq-block) open "noodle" 9 | (lg-seq-block) writing "noodle" 10 | (lg-seq-block) close "noodle" 11 | (lg-seq-block) open "noodle" for verification 12 | (lg-seq-block) verified contents of "noodle" 13 | (lg-seq-block) close "noodle" 14 | (lg-seq-block) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-seq-random.c: -------------------------------------------------------------------------------- 1 | /* Writes out a fairly large file sequentially, one random-sized 2 | block at a time, then reads it back to verify that it was 3 | written properly. */ 4 | 5 | #define TEST_SIZE 75678 6 | #include "tests/filesys/base/seq-random.inc" 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/lg-seq-random.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (lg-seq-random) begin 7 | (lg-seq-random) create "nibble" 8 | (lg-seq-random) open "nibble" 9 | (lg-seq-random) writing "nibble" 10 | (lg-seq-random) close "nibble" 11 | (lg-seq-random) open "nibble" for verification 12 | (lg-seq-random) verified contents of "nibble" 13 | (lg-seq-random) close "nibble" 14 | (lg-seq-random) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/seq-block.inc: -------------------------------------------------------------------------------- 1 | /* -*- c -*- */ 2 | 3 | #include "tests/filesys/seq-test.h" 4 | #include "tests/main.h" 5 | 6 | static char buf[TEST_SIZE]; 7 | 8 | static size_t 9 | return_block_size (void) 10 | { 11 | return BLOCK_SIZE; 12 | } 13 | 14 | void 15 | test_main (void) 16 | { 17 | seq_test ("noodle", 18 | buf, sizeof buf, sizeof buf, 19 | return_block_size, NULL); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/seq-random.inc: -------------------------------------------------------------------------------- 1 | /* -*- c -*- */ 2 | 3 | #include 4 | #include "tests/filesys/seq-test.h" 5 | #include "tests/main.h" 6 | 7 | static char buf[TEST_SIZE]; 8 | 9 | static size_t 10 | return_random (void) 11 | { 12 | return random_ulong () % 1031 + 1; 13 | } 14 | 15 | void 16 | test_main (void) 17 | { 18 | random_init (-1); 19 | seq_test ("nibble", 20 | buf, sizeof buf, sizeof buf, 21 | return_random, NULL); 22 | } 23 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-create.c: -------------------------------------------------------------------------------- 1 | /* Tests that create properly zeros out the contents of a fairly 2 | small file. */ 3 | 4 | #define TEST_SIZE 5678 5 | #include "tests/filesys/create.inc" 6 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-create.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (sm-create) begin 7 | (sm-create) create "blargle" 8 | (sm-create) open "blargle" for verification 9 | (sm-create) verified contents of "blargle" 10 | (sm-create) close "blargle" 11 | (sm-create) end 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-full.c: -------------------------------------------------------------------------------- 1 | /* Writes out the contents of a fairly small file all at once, 2 | and then reads it back to make sure that it was written 3 | properly. */ 4 | 5 | #define TEST_SIZE 5678 6 | #include "tests/filesys/base/full.inc" 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-full.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (sm-full) begin 7 | (sm-full) create "quux" 8 | (sm-full) open "quux" 9 | (sm-full) writing "quux" 10 | (sm-full) close "quux" 11 | (sm-full) open "quux" for verification 12 | (sm-full) verified contents of "quux" 13 | (sm-full) close "quux" 14 | (sm-full) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-random.c: -------------------------------------------------------------------------------- 1 | /* Writes out the content of a fairly small file in random order, 2 | then reads it back in random order to verify that it was 3 | written properly. */ 4 | 5 | #define BLOCK_SIZE 13 6 | #define TEST_SIZE (13 * 123) 7 | #include "tests/filesys/base/random.inc" 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-random.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (sm-random) begin 7 | (sm-random) create "bazzle" 8 | (sm-random) open "bazzle" 9 | (sm-random) write "bazzle" in random order 10 | (sm-random) read "bazzle" in random order 11 | (sm-random) close "bazzle" 12 | (sm-random) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-seq-block.c: -------------------------------------------------------------------------------- 1 | /* Writes out a fairly small file sequentially, one fixed-size 2 | block at a time, then reads it back to verify that it was 3 | written properly. */ 4 | 5 | #define TEST_SIZE 5678 6 | #define BLOCK_SIZE 513 7 | #include "tests/filesys/base/seq-block.inc" 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-seq-block.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (sm-seq-block) begin 7 | (sm-seq-block) create "noodle" 8 | (sm-seq-block) open "noodle" 9 | (sm-seq-block) writing "noodle" 10 | (sm-seq-block) close "noodle" 11 | (sm-seq-block) open "noodle" for verification 12 | (sm-seq-block) verified contents of "noodle" 13 | (sm-seq-block) close "noodle" 14 | (sm-seq-block) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-seq-random.c: -------------------------------------------------------------------------------- 1 | /* Writes out a fairly large file sequentially, one random-sized 2 | block at a time, then reads it back to verify that it was 3 | written properly. */ 4 | 5 | #define TEST_SIZE 5678 6 | #include "tests/filesys/base/seq-random.inc" 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/sm-seq-random.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (sm-seq-random) begin 7 | (sm-seq-random) create "nibble" 8 | (sm-seq-random) open "nibble" 9 | (sm-seq-random) writing "nibble" 10 | (sm-seq-random) close "nibble" 11 | (sm-seq-random) open "nibble" for verification 12 | (sm-seq-random) verified contents of "nibble" 13 | (sm-seq-random) close "nibble" 14 | (sm-seq-random) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/syn-read.c: -------------------------------------------------------------------------------- 1 | /* Spawns 10 child processes, all of which read from the same 2 | file and make sure that the contents are what they should 3 | be. */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "tests/lib.h" 9 | #include "tests/main.h" 10 | #include "tests/filesys/base/syn-read.h" 11 | 12 | static char buf[BUF_SIZE]; 13 | 14 | #define CHILD_CNT 10 15 | 16 | void 17 | test_main (void) 18 | { 19 | pid_t children[CHILD_CNT]; 20 | int fd; 21 | 22 | CHECK (create (file_name, sizeof buf), "create \"%s\"", file_name); 23 | CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); 24 | random_bytes (buf, sizeof buf); 25 | CHECK (write (fd, buf, sizeof buf) > 0, "write \"%s\"", file_name); 26 | msg ("close \"%s\"", file_name); 27 | close (fd); 28 | 29 | exec_children ("child-syn-read", children, CHILD_CNT); 30 | wait_children (children, CHILD_CNT); 31 | } 32 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/syn-read.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_FILESYS_BASE_SYN_READ_H 2 | #define TESTS_FILESYS_BASE_SYN_READ_H 3 | 4 | #define BUF_SIZE 1024 5 | static const char file_name[] = "data"; 6 | 7 | #endif /* tests/filesys/base/syn-read.h */ 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/syn-remove.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (syn-remove) begin 7 | (syn-remove) create "deleteme" 8 | (syn-remove) open "deleteme" 9 | (syn-remove) remove "deleteme" 10 | (syn-remove) write "deleteme" 11 | (syn-remove) seek "deleteme" to 0 12 | (syn-remove) read "deleteme" 13 | (syn-remove) close "deleteme" 14 | (syn-remove) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/base/syn-write.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_FILESYS_BASE_SYN_WRITE_H 2 | #define TESTS_FILESYS_BASE_SYN_WRITE_H 3 | 4 | #define CHILD_CNT 10 5 | #define CHUNK_SIZE 512 6 | #define BUF_SIZE (CHILD_CNT * CHUNK_SIZE) 7 | static const char file_name[] = "stuff"; 8 | 9 | #endif /* tests/filesys/base/syn-write.h */ 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/create.inc: -------------------------------------------------------------------------------- 1 | /* -*- c -*- */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | static char buf[TEST_SIZE]; 8 | 9 | void 10 | test_main (void) 11 | { 12 | const char *file_name = "blargle"; 13 | CHECK (create (file_name, TEST_SIZE), "create \"%s\"", file_name); 14 | check_file (file_name, buf, TEST_SIZE); 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/Rubric.functionality: -------------------------------------------------------------------------------- 1 | Functionality of extended file system: 2 | - Test directory support. 3 | 1 dir-mkdir 4 | 3 dir-mk-tree 5 | 6 | 1 dir-rmdir 7 | 3 dir-rm-tree 8 | 9 | 5 dir-vine 10 | 11 | - Test file growth. 12 | 1 grow-create 13 | 1 grow-seq-sm 14 | 3 grow-seq-lg 15 | 3 grow-sparse 16 | 3 grow-two-files 17 | 1 grow-tell 18 | 1 grow-file-size 19 | 20 | - Test directory growth. 21 | 1 grow-dir-lg 22 | 1 grow-root-sm 23 | 1 grow-root-lg 24 | 25 | - Test writing from multiple processes. 26 | 5 syn-rw 27 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/Rubric.persistence: -------------------------------------------------------------------------------- 1 | Persistence of file system: 2 | 1 dir-empty-name-persistence 3 | 1 dir-mk-tree-persistence 4 | 1 dir-mkdir-persistence 5 | 1 dir-open-persistence 6 | 1 dir-over-file-persistence 7 | 1 dir-rm-cwd-persistence 8 | 1 dir-rm-parent-persistence 9 | 1 dir-rm-root-persistence 10 | 1 dir-rm-tree-persistence 11 | 1 dir-rmdir-persistence 12 | 1 dir-under-file-persistence 13 | 1 dir-vine-persistence 14 | 1 grow-create-persistence 15 | 1 grow-dir-lg-persistence 16 | 1 grow-file-size-persistence 17 | 1 grow-root-lg-persistence 18 | 1 grow-root-sm-persistence 19 | 1 grow-seq-lg-persistence 20 | 1 grow-seq-sm-persistence 21 | 1 grow-sparse-persistence 22 | 1 grow-tell-persistence 23 | 1 grow-two-files-persistence 24 | 1 syn-rw-persistence 25 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/Rubric.robustness: -------------------------------------------------------------------------------- 1 | Robustness of file system: 2 | 1 dir-empty-name 3 | 1 dir-open 4 | 1 dir-over-file 5 | 1 dir-under-file 6 | 7 | 3 dir-rm-cwd 8 | 2 dir-rm-parent 9 | 1 dir-rm-root 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-empty-name-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-empty-name.c: -------------------------------------------------------------------------------- 1 | /* Tries to create a directory named as the empty string, 2 | which must return failure. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (!mkdir (""), "mkdir \"\" (must return false)"); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-empty-name.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-empty-name) begin 7 | (dir-empty-name) mkdir "" (must return false) 8 | (dir-empty-name) end 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-mk-tree-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | my ($tree); 6 | for my $a (0...3) { 7 | for my $b (0...2) { 8 | for my $c (0...2) { 9 | for my $d (0...3) { 10 | $tree->{$a}{$b}{$c}{$d} = ['']; 11 | } 12 | } 13 | } 14 | } 15 | check_archive ($tree); 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-mk-tree.c: -------------------------------------------------------------------------------- 1 | /* Creates directories /0/0/0 through /3/2/2 and creates files in 2 | the leaf directories. */ 3 | 4 | #include "tests/filesys/extended/mk-tree.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | make_tree (4, 3, 3, 4); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-mk-tree.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-mk-tree) begin 7 | (dir-mk-tree) creating /0/0/0/0 through /3/2/2/3... 8 | (dir-mk-tree) open "/0/2/0/3" 9 | (dir-mk-tree) close "/0/2/0/3" 10 | (dir-mk-tree) end 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-mkdir-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({'a' => {'b' => ["\0" x 512]}}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-mkdir.c: -------------------------------------------------------------------------------- 1 | /* Tests mkdir(). */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | CHECK (mkdir ("a"), "mkdir \"a\""); 11 | CHECK (create ("a/b", 512), "create \"a/b\""); 12 | CHECK (chdir ("a"), "chdir \"a\""); 13 | CHECK (open ("b") > 1, "open \"b\""); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-mkdir.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-mkdir) begin 7 | (dir-mkdir) mkdir "a" 8 | (dir-mkdir) create "a/b" 9 | (dir-mkdir) chdir "a" 10 | (dir-mkdir) open "b" 11 | (dir-mkdir) end 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-open-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"xyzzy" => {}}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-open.c: -------------------------------------------------------------------------------- 1 | /* Opens a directory, then tries to write to it, which must 2 | fail. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int fd; 12 | int retval; 13 | 14 | CHECK (mkdir ("xyzzy"), "mkdir \"xyzzy\""); 15 | CHECK ((fd = open ("xyzzy")) > 1, "open \"xyzzy\""); 16 | 17 | msg ("write \"xyzzy\""); 18 | retval = write (fd, "foobar", 6); 19 | CHECK (retval == -1, 20 | "write \"xyzzy\" (must return -1, actually %d)", retval); 21 | } 22 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-open.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (dir-open) begin 7 | (dir-open) mkdir "xyzzy" 8 | (dir-open) open "xyzzy" 9 | (dir-open) write "xyzzy" 10 | (dir-open) write "xyzzy" (must return -1, actually -1) 11 | (dir-open) end 12 | dir-open: exit(0) 13 | EOF 14 | (dir-open) begin 15 | (dir-open) mkdir "xyzzy" 16 | (dir-open) open "xyzzy" 17 | (dir-open) write "xyzzy" 18 | dir-open: exit(-1) 19 | EOF 20 | pass; 21 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-over-file-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"abc" => {}}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-over-file.c: -------------------------------------------------------------------------------- 1 | /* Tries to create a file with the same name as an existing 2 | directory, which must return failure. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (mkdir ("abc"), "mkdir \"abc\""); 12 | CHECK (!create ("abc", 0), "create \"abc\" (must return false)"); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-over-file.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-over-file) begin 7 | (dir-over-file) mkdir "abc" 8 | (dir-over-file) create "abc" (must return false) 9 | (dir-over-file) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-cwd-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | my ($cwd_removable) = read_text_file ("tests/filesys/extended/can-rmdir-cwd"); 6 | $cwd_removable eq 'YES' || $cwd_removable eq 'NO' or die; 7 | check_archive ($cwd_removable eq 'YES' ? {} : {"a" => {}}); 8 | pass; 9 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-parent-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"a" => {"b" => {}}}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-parent.c: -------------------------------------------------------------------------------- 1 | /* Tries to remove a parent of the current directory. This must 2 | fail, because that directory is non-empty. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (mkdir ("a"), "mkdir \"a\""); 12 | CHECK (chdir ("a"), "chdir \"a\""); 13 | CHECK (mkdir ("b"), "mkdir \"b\""); 14 | CHECK (chdir ("b"), "chdir \"b\""); 15 | CHECK (!remove ("/a"), "remove \"/a\" (must fail)"); 16 | } 17 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-parent.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-rm-parent) begin 7 | (dir-rm-parent) mkdir "a" 8 | (dir-rm-parent) chdir "a" 9 | (dir-rm-parent) mkdir "b" 10 | (dir-rm-parent) chdir "b" 11 | (dir-rm-parent) remove "/a" (must fail) 12 | (dir-rm-parent) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-root-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"a" => ["\0" x 243]}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-root.c: -------------------------------------------------------------------------------- 1 | /* Try to remove the root directory. 2 | This must fail. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (!remove ("/"), "remove \"/\" (must fail)"); 12 | CHECK (create ("/a", 243), "create \"/a\""); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-root.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-rm-root) begin 7 | (dir-rm-root) remove "/" (must fail) 8 | (dir-rm-root) create "/a" 9 | (dir-rm-root) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-tree-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rm-tree.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-rm-tree) begin 7 | (dir-rm-tree) creating /0/0/0/0 through /3/2/2/3... 8 | (dir-rm-tree) open "/0/2/0/3" 9 | (dir-rm-tree) close "/0/2/0/3" 10 | (dir-rm-tree) removing /0/0/0/0 through /3/2/2/3... 11 | (dir-rm-tree) open "/3/0/2/0" (must return -1) 12 | (dir-rm-tree) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rmdir-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rmdir.c: -------------------------------------------------------------------------------- 1 | /* Creates and removes a directory, then makes sure that it's 2 | really gone. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (mkdir ("a"), "mkdir \"a\""); 12 | CHECK (remove ("a"), "rmdir \"a\""); 13 | CHECK (!chdir ("a"), "chdir \"a\" (must return false)"); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-rmdir.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-rmdir) begin 7 | (dir-rmdir) mkdir "a" 8 | (dir-rmdir) rmdir "a" 9 | (dir-rmdir) chdir "a" (must return false) 10 | (dir-rmdir) end 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-under-file-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"abc" => ['']}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-under-file.c: -------------------------------------------------------------------------------- 1 | /* Tries to create a directory with the same name as an existing 2 | file, which must return failure. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (create ("abc", 0), "create \"abc\""); 12 | CHECK (!mkdir ("abc"), "mkdir \"abc\" (must return false)"); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-under-file.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-under-file) begin 7 | (dir-under-file) create "abc" 8 | (dir-under-file) mkdir "abc" (must return false) 9 | (dir-under-file) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/dir-vine.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (dir-vine) begin 7 | (dir-vine) creating many levels of files and directories... 8 | (dir-vine) removing all but top 10 levels of files and directories... 9 | (dir-vine) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-create-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"blargle" => ['']}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-create.c: -------------------------------------------------------------------------------- 1 | /* Create a file of size 0. */ 2 | 3 | #define TEST_SIZE 0 4 | #include "tests/filesys/create.inc" 5 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-create.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (grow-create) begin 7 | (grow-create) create "blargle" 8 | (grow-create) open "blargle" for verification 9 | (grow-create) verified contents of "blargle" 10 | (grow-create) close "blargle" 11 | (grow-create) end 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-dir-lg-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | my ($fs); 7 | $fs->{'x'}{"file$_"} = [random_bytes (512)] foreach 0...49; 8 | check_archive ($fs); 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-dir-lg.c: -------------------------------------------------------------------------------- 1 | /* Creates a directory, 2 | then creates 50 files in that directory. */ 3 | 4 | #define FILE_CNT 50 5 | #define DIRECTORY "/x" 6 | #include "tests/filesys/extended/grow-dir.inc" 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-file-size-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"testfile" => [random_bytes (2134)]}); 7 | pass; 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-file-size.c: -------------------------------------------------------------------------------- 1 | /* Grows a file from 0 bytes to 2,134 bytes, 37 bytes at a time, 2 | and checks that the file's size is reported correctly at each 3 | step. */ 4 | 5 | #include 6 | #include "tests/filesys/seq-test.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | static char buf[2134]; 11 | 12 | static size_t 13 | return_block_size (void) 14 | { 15 | return 37; 16 | } 17 | 18 | static void 19 | check_file_size (int fd, long ofs) 20 | { 21 | long size = filesize (fd); 22 | if (size != ofs) 23 | fail ("filesize not updated properly: should be %ld, actually %ld", 24 | ofs, size); 25 | } 26 | 27 | void 28 | test_main (void) 29 | { 30 | seq_test ("testfile", 31 | buf, sizeof buf, 0, 32 | return_block_size, check_file_size); 33 | } 34 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-file-size.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 7 | (grow-file-size) begin 8 | (grow-file-size) create "testfile" 9 | (grow-file-size) open "testfile" 10 | (grow-file-size) writing "testfile" 11 | (grow-file-size) close "testfile" 12 | (grow-file-size) open "testfile" for verification 13 | (grow-file-size) verified contents of "testfile" 14 | (grow-file-size) close "testfile" 15 | (grow-file-size) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-root-lg-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | my ($fs); 7 | $fs->{"file$_"} = [random_bytes (512)] foreach 0...49; 8 | check_archive ($fs); 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-root-lg.c: -------------------------------------------------------------------------------- 1 | /* Creates 50 files in the root directory. */ 2 | 3 | #define FILE_CNT 50 4 | #include "tests/filesys/extended/grow-dir.inc" 5 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-root-sm-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | my ($fs); 7 | $fs->{"file$_"} = [random_bytes (512)] foreach 0...19; 8 | check_archive ($fs); 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-root-sm.c: -------------------------------------------------------------------------------- 1 | /* Creates 20 files in the root directory. */ 2 | 3 | #define FILE_CNT 20 4 | #include "tests/filesys/extended/grow-dir.inc" 5 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq-lg-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"testme" => [random_bytes (72943)]}); 7 | pass; 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq-lg.c: -------------------------------------------------------------------------------- 1 | /* Grows a file from 0 bytes to 72,943 bytes, 1,234 bytes at a 2 | time. */ 3 | 4 | #define TEST_SIZE 72943 5 | #include "tests/filesys/extended/grow-seq.inc" 6 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq-lg.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 7 | (grow-seq-lg) begin 8 | (grow-seq-lg) create "testme" 9 | (grow-seq-lg) open "testme" 10 | (grow-seq-lg) writing "testme" 11 | (grow-seq-lg) close "testme" 12 | (grow-seq-lg) open "testme" for verification 13 | (grow-seq-lg) verified contents of "testme" 14 | (grow-seq-lg) close "testme" 15 | (grow-seq-lg) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq-sm-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"testme" => [random_bytes (5678)]}); 7 | pass; 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq-sm.c: -------------------------------------------------------------------------------- 1 | /* Grows a file from 0 bytes to 5,678 bytes, 1,234 bytes at a 2 | time. */ 3 | 4 | #define TEST_SIZE 5678 5 | #include "tests/filesys/extended/grow-seq.inc" 6 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq-sm.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 7 | (grow-seq-sm) begin 8 | (grow-seq-sm) create "testme" 9 | (grow-seq-sm) open "testme" 10 | (grow-seq-sm) writing "testme" 11 | (grow-seq-sm) close "testme" 12 | (grow-seq-sm) open "testme" for verification 13 | (grow-seq-sm) verified contents of "testme" 14 | (grow-seq-sm) close "testme" 15 | (grow-seq-sm) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-seq.inc: -------------------------------------------------------------------------------- 1 | /* -*- c -*- */ 2 | 3 | #include "tests/filesys/seq-test.h" 4 | #include "tests/main.h" 5 | 6 | static char buf[TEST_SIZE]; 7 | 8 | static size_t 9 | return_block_size (void) 10 | { 11 | return 1234; 12 | } 13 | 14 | void 15 | test_main (void) 16 | { 17 | seq_test ("testme", 18 | buf, sizeof buf, 0, 19 | return_block_size, NULL); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-sparse-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_archive ({"testfile" => ["\0" x 76543]}); 6 | pass; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-sparse.c: -------------------------------------------------------------------------------- 1 | /* Tests that seeking past the end of a file and writing will 2 | properly zero out the region in between. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | static char buf[76543]; 9 | 10 | void 11 | test_main (void) 12 | { 13 | const char *file_name = "testfile"; 14 | char zero = 0; 15 | int fd; 16 | 17 | CHECK (create (file_name, 0), "create \"%s\"", file_name); 18 | CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name); 19 | msg ("seek \"%s\"", file_name); 20 | seek (fd, sizeof buf - 1); 21 | CHECK (write (fd, &zero, 1) > 0, "write \"%s\"", file_name); 22 | msg ("close \"%s\"", file_name); 23 | close (fd); 24 | check_file (file_name, buf, sizeof buf); 25 | } 26 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-sparse.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (grow-sparse) begin 7 | (grow-sparse) create "testfile" 8 | (grow-sparse) open "testfile" 9 | (grow-sparse) seek "testfile" 10 | (grow-sparse) write "testfile" 11 | (grow-sparse) close "testfile" 12 | (grow-sparse) open "testfile" for verification 13 | (grow-sparse) verified contents of "testfile" 14 | (grow-sparse) close "testfile" 15 | (grow-sparse) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-tell-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"foobar" => [random_bytes (2134)]}); 7 | pass; 8 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-tell.c: -------------------------------------------------------------------------------- 1 | /* Checks that growing a file updates the file position 2 | correctly. */ 3 | 4 | #include 5 | #include "tests/filesys/seq-test.h" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | static char buf[2134]; 10 | 11 | static size_t 12 | return_block_size (void) 13 | { 14 | return 37; 15 | } 16 | 17 | static void 18 | check_tell (int fd, long ofs) 19 | { 20 | long pos = tell (fd); 21 | if (pos != ofs) 22 | fail ("file position not updated properly: should be %ld, actually %ld", 23 | ofs, pos); 24 | } 25 | 26 | void 27 | test_main (void) 28 | { 29 | seq_test ("foobar", 30 | buf, sizeof buf, 0, 31 | return_block_size, check_tell); 32 | } 33 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-tell.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 7 | (grow-tell) begin 8 | (grow-tell) create "foobar" 9 | (grow-tell) open "foobar" 10 | (grow-tell) writing "foobar" 11 | (grow-tell) close "foobar" 12 | (grow-tell) open "foobar" for verification 13 | (grow-tell) verified contents of "foobar" 14 | (grow-tell) close "foobar" 15 | (grow-tell) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-two-files-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | my ($a) = random_bytes (8143); 7 | my ($b) = random_bytes (8143); 8 | check_archive ({"a" => [$a], "b" => [$b]}); 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/grow-two-files.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 7 | (grow-two-files) begin 8 | (grow-two-files) create "a" 9 | (grow-two-files) create "b" 10 | (grow-two-files) open "a" 11 | (grow-two-files) open "b" 12 | (grow-two-files) write "a" and "b" alternately 13 | (grow-two-files) close "a" 14 | (grow-two-files) close "b" 15 | (grow-two-files) open "a" for verification 16 | (grow-two-files) verified contents of "a" 17 | (grow-two-files) close "a" 18 | (grow-two-files) open "b" for verification 19 | (grow-two-files) verified contents of "b" 20 | (grow-two-files) close "b" 21 | (grow-two-files) end 22 | EOF 23 | pass; 24 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/mk-tree.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_FILESYS_EXTENDED_MK_TREE_H 2 | #define TESTS_FILESYS_EXTENDED_MK_TREE_H 3 | 4 | void make_tree (int at, int bt, int ct, int dt); 5 | 6 | #endif /* tests/filesys/extended/mk-tree.h */ 7 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/syn-rw-persistence.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_archive ({"child-syn-rw" => "tests/filesys/extended/child-syn-rw", 7 | "logfile" => [random_bytes (8 * 512)]}); 8 | pass; 9 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/syn-rw.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::random; 6 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 7 | (syn-rw) begin 8 | (syn-rw) create "logfile" 9 | (syn-rw) open "logfile" 10 | (syn-rw) exec child 1 of 4: "child-syn-rw 0" 11 | (syn-rw) exec child 2 of 4: "child-syn-rw 1" 12 | (syn-rw) exec child 3 of 4: "child-syn-rw 2" 13 | (syn-rw) exec child 4 of 4: "child-syn-rw 3" 14 | (syn-rw) wait for child 1 of 4 returned 0 (expected 0) 15 | (syn-rw) wait for child 2 of 4 returned 1 (expected 1) 16 | (syn-rw) wait for child 3 of 4 returned 2 (expected 2) 17 | (syn-rw) wait for child 4 of 4 returned 3 (expected 3) 18 | (syn-rw) end 19 | EOF 20 | pass; 21 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/extended/syn-rw.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_FILESYS_EXTENDED_SYN_RW_H 2 | #define TESTS_FILESYS_EXTENDED_SYN_RW_H 3 | 4 | #define CHUNK_SIZE 8 5 | #define CHUNK_CNT 512 6 | #define BUF_SIZE (CHUNK_SIZE * CHUNK_CNT) 7 | static const char file_name[] = "logfile"; 8 | 9 | #endif /* tests/filesys/extended/syn-rw.h */ 10 | -------------------------------------------------------------------------------- /pintos/src/tests/filesys/seq-test.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_FILESYS_SEQ_TEST_H 2 | #define TESTS_FILESYS_SEQ_TEST_H 3 | 4 | #include 5 | 6 | void seq_test (const char *file_name, 7 | void *buf, size_t size, size_t initial_size, 8 | size_t (*block_size_func) (void), 9 | void (*check_func) (int fd, long ofs)); 10 | 11 | #endif /* tests/filesys/seq-test.h */ 12 | -------------------------------------------------------------------------------- /pintos/src/tests/lib.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use tests::random; 5 | 6 | sub shuffle { 7 | my ($in, $cnt, $sz) = @_; 8 | $cnt * $sz == length $in or die; 9 | my (@a) = 0...$cnt - 1; 10 | for my $i (0...$cnt - 1) { 11 | my ($j) = $i + random_ulong () % ($cnt - $i); 12 | @a[$i, $j] = @a[$j, $i]; 13 | } 14 | my ($out) = ""; 15 | $out .= substr ($in, $_ * $sz, $sz) foreach @a; 16 | return $out; 17 | } 18 | 19 | 1; 20 | -------------------------------------------------------------------------------- /pintos/src/tests/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "tests/lib.h" 3 | #include "tests/main.h" 4 | 5 | int 6 | main (int argc UNUSED, char *argv[]) 7 | { 8 | test_name = argv[0]; 9 | 10 | msg ("begin"); 11 | random_init (0); 12 | test_main (); 13 | msg ("end"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/main.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_MAIN_H 2 | #define TESTS_MAIN_H 3 | 4 | void test_main (void); 5 | 6 | #endif /* tests/main.h */ 7 | -------------------------------------------------------------------------------- /pintos/src/tests/random.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use tests::arc4; 5 | 6 | my (@arc4); 7 | 8 | sub random_init { 9 | if (@arc4 == 0) { 10 | my ($seed) = @_; 11 | $seed = 0 if !defined $seed; 12 | @arc4 = arc4_init (pack ("V", $seed)); 13 | } 14 | } 15 | 16 | sub random_bytes { 17 | random_init (); 18 | my ($n) = @_; 19 | return arc4_crypt (\@arc4, "\0" x $n); 20 | } 21 | 22 | sub random_ulong { 23 | random_init (); 24 | return unpack ("V", random_bytes (4)); 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/Grading: -------------------------------------------------------------------------------- 1 | # Percentage of the testing point total designated for each set of 2 | # tests. 3 | 4 | 20.0% tests/threads/Rubric.alarm 5 | 40.0% tests/threads/Rubric.priority 6 | 40.0% tests/threads/Rubric.mlfqs 7 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/Rubric.alarm: -------------------------------------------------------------------------------- 1 | Functionality and robustness of alarm clock: 2 | 4 alarm-single 3 | 4 alarm-multiple 4 | 4 alarm-simultaneous 5 | 4 alarm-priority 6 | 7 | 1 alarm-zero 8 | 1 alarm-negative 9 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/Rubric.mlfqs: -------------------------------------------------------------------------------- 1 | Functionality of advanced scheduler: 2 | 5 mlfqs-load-1 3 | 5 mlfqs-load-60 4 | 3 mlfqs-load-avg 5 | 6 | 5 mlfqs-recent-1 7 | 8 | 5 mlfqs-fair-2 9 | 3 mlfqs-fair-20 10 | 11 | 4 mlfqs-nice-2 12 | 2 mlfqs-nice-10 13 | 14 | 5 mlfqs-block 15 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/Rubric.priority: -------------------------------------------------------------------------------- 1 | Functionality of priority scheduler: 2 | 3 priority-change 3 | 3 priority-preempt 4 | 5 | 3 priority-fifo 6 | 3 priority-sema 7 | 3 priority-condvar 8 | 9 | 3 priority-donate-one 10 | 3 priority-donate-multiple 11 | 3 priority-donate-multiple2 12 | 3 priority-donate-nest 13 | 5 priority-donate-chain 14 | 3 priority-donate-sema 15 | 3 priority-donate-lower 16 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-multiple.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use tests::tests; 3 | use tests::threads::alarm; 4 | check_alarm (7); 5 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-negative.c: -------------------------------------------------------------------------------- 1 | /* Tests timer_sleep(-100). Only requirement is that it not crash. */ 2 | 3 | #include 4 | #include "tests/threads/tests.h" 5 | #include "threads/malloc.h" 6 | #include "threads/synch.h" 7 | #include "threads/thread.h" 8 | #include "devices/timer.h" 9 | 10 | void 11 | test_alarm_negative (void) 12 | { 13 | timer_sleep (-100); 14 | pass (); 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-negative.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (alarm-negative) begin 7 | (alarm-negative) PASS 8 | (alarm-negative) end 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-priority.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (alarm-priority) begin 7 | (alarm-priority) Thread priority 30 woke up. 8 | (alarm-priority) Thread priority 29 woke up. 9 | (alarm-priority) Thread priority 28 woke up. 10 | (alarm-priority) Thread priority 27 woke up. 11 | (alarm-priority) Thread priority 26 woke up. 12 | (alarm-priority) Thread priority 25 woke up. 13 | (alarm-priority) Thread priority 24 woke up. 14 | (alarm-priority) Thread priority 23 woke up. 15 | (alarm-priority) Thread priority 22 woke up. 16 | (alarm-priority) Thread priority 21 woke up. 17 | (alarm-priority) end 18 | EOF 19 | pass; 20 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-single.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use tests::tests; 3 | use tests::threads::alarm; 4 | check_alarm (1); 5 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-zero.c: -------------------------------------------------------------------------------- 1 | /* Tests timer_sleep(0), which should return immediately. */ 2 | 3 | #include 4 | #include "tests/threads/tests.h" 5 | #include "threads/malloc.h" 6 | #include "threads/synch.h" 7 | #include "threads/thread.h" 8 | #include "devices/timer.h" 9 | 10 | void 11 | test_alarm_zero (void) 12 | { 13 | timer_sleep (0); 14 | pass (); 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm-zero.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (alarm-zero) begin 7 | (alarm-zero) PASS 8 | (alarm-zero) end 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/alarm.pm: -------------------------------------------------------------------------------- 1 | sub check_alarm { 2 | my ($iterations) = @_; 3 | our ($test); 4 | 5 | @output = read_text_file ("$test.output"); 6 | common_checks ("run", @output); 7 | 8 | my (@products); 9 | for (my ($i) = 0; $i < $iterations; $i++) { 10 | for (my ($t) = 0; $t < 5; $t++) { 11 | push (@products, ($i + 1) * ($t + 1) * 10); 12 | } 13 | } 14 | @products = sort {$a <=> $b} @products; 15 | 16 | local ($_); 17 | foreach (@output) { 18 | fail $_ if /out of order/i; 19 | 20 | my ($p) = /product=(\d+)$/; 21 | next if !defined $p; 22 | 23 | my ($q) = shift (@products); 24 | fail "Too many wakeups.\n" if !defined $q; 25 | fail "Out of order wakeups ($p vs. $q).\n" if $p != $q; # FIXME 26 | } 27 | fail scalar (@products) . " fewer wakeups than expected.\n" 28 | if @products != 0; 29 | pass; 30 | } 31 | 32 | 1; 33 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/mlfqs-block.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (mlfqs-block) begin 7 | (mlfqs-block) Main thread acquiring lock. 8 | (mlfqs-block) Main thread creating block thread, sleeping 25 seconds... 9 | (mlfqs-block) Block thread spinning for 20 seconds... 10 | (mlfqs-block) Block thread acquiring lock... 11 | (mlfqs-block) Main thread spinning for 5 seconds... 12 | (mlfqs-block) Main thread releasing lock. 13 | (mlfqs-block) ...got it. 14 | (mlfqs-block) Block thread should have already acquired lock. 15 | (mlfqs-block) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/mlfqs-fair-2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::threads::mlfqs; 6 | 7 | check_mlfqs_fair ([0, 0], 50); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/mlfqs-fair-20.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::threads::mlfqs; 6 | 7 | check_mlfqs_fair ([(0) x 20], 20); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/mlfqs-load-1.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | 6 | our ($test); 7 | my (@output) = read_text_file ("$test.output"); 8 | 9 | common_checks ("run", @output); 10 | 11 | @output = get_core_output ("run", @output); 12 | fail "missing PASS in output" 13 | unless grep ($_ eq '(mlfqs-load-1) PASS', @output); 14 | 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/mlfqs-nice-10.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::threads::mlfqs; 6 | 7 | check_mlfqs_fair ([0...9], 25); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/mlfqs-nice-2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::threads::mlfqs; 6 | 7 | check_mlfqs_fair ([0, 5], 50); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-change.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-change) begin 7 | (priority-change) Creating a high-priority thread 2. 8 | (priority-change) Thread 2 now lowering priority. 9 | (priority-change) Thread 2 should have just lowered its priority. 10 | (priority-change) Thread 2 exiting. 11 | (priority-change) Thread 2 should have just exited. 12 | (priority-change) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-donate-lower.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-donate-lower) begin 7 | (priority-donate-lower) Main thread should have priority 41. Actual priority: 41. 8 | (priority-donate-lower) Lowering base priority... 9 | (priority-donate-lower) Main thread should have priority 41. Actual priority: 41. 10 | (priority-donate-lower) acquire: got the lock 11 | (priority-donate-lower) acquire: done 12 | (priority-donate-lower) acquire must already have finished. 13 | (priority-donate-lower) Main thread should have priority 21. Actual priority: 21. 14 | (priority-donate-lower) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-donate-multiple.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-donate-multiple) begin 7 | (priority-donate-multiple) Main thread should have priority 32. Actual priority: 32. 8 | (priority-donate-multiple) Main thread should have priority 33. Actual priority: 33. 9 | (priority-donate-multiple) Thread b acquired lock b. 10 | (priority-donate-multiple) Thread b finished. 11 | (priority-donate-multiple) Thread b should have just finished. 12 | (priority-donate-multiple) Main thread should have priority 32. Actual priority: 32. 13 | (priority-donate-multiple) Thread a acquired lock a. 14 | (priority-donate-multiple) Thread a finished. 15 | (priority-donate-multiple) Thread a should have just finished. 16 | (priority-donate-multiple) Main thread should have priority 31. Actual priority: 31. 17 | (priority-donate-multiple) end 18 | EOF 19 | pass; 20 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-donate-multiple2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-donate-multiple2) begin 7 | (priority-donate-multiple2) Main thread should have priority 34. Actual priority: 34. 8 | (priority-donate-multiple2) Main thread should have priority 36. Actual priority: 36. 9 | (priority-donate-multiple2) Main thread should have priority 36. Actual priority: 36. 10 | (priority-donate-multiple2) Thread b acquired lock b. 11 | (priority-donate-multiple2) Thread b finished. 12 | (priority-donate-multiple2) Thread a acquired lock a. 13 | (priority-donate-multiple2) Thread a finished. 14 | (priority-donate-multiple2) Thread c finished. 15 | (priority-donate-multiple2) Threads b, a, c should have just finished, in that order. 16 | (priority-donate-multiple2) Main thread should have priority 31. Actual priority: 31. 17 | (priority-donate-multiple2) end 18 | EOF 19 | pass; 20 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-donate-nest.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-donate-nest) begin 7 | (priority-donate-nest) Low thread should have priority 32. Actual priority: 32. 8 | (priority-donate-nest) Low thread should have priority 33. Actual priority: 33. 9 | (priority-donate-nest) Medium thread should have priority 33. Actual priority: 33. 10 | (priority-donate-nest) Medium thread got the lock. 11 | (priority-donate-nest) High thread got the lock. 12 | (priority-donate-nest) High thread finished. 13 | (priority-donate-nest) High thread should have just finished. 14 | (priority-donate-nest) Middle thread finished. 15 | (priority-donate-nest) Medium thread should just have finished. 16 | (priority-donate-nest) Low thread should have priority 31. Actual priority: 31. 17 | (priority-donate-nest) end 18 | EOF 19 | pass; 20 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-donate-one.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-donate-one) begin 7 | (priority-donate-one) This thread should have priority 32. Actual priority: 32. 8 | (priority-donate-one) This thread should have priority 33. Actual priority: 33. 9 | (priority-donate-one) acquire2: got the lock 10 | (priority-donate-one) acquire2: done 11 | (priority-donate-one) acquire1: got the lock 12 | (priority-donate-one) acquire1: done 13 | (priority-donate-one) acquire2, acquire1 must already have finished, in that order. 14 | (priority-donate-one) This should be the last line before finishing this test. 15 | (priority-donate-one) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-donate-sema.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-donate-sema) begin 7 | (priority-donate-sema) Thread L acquired lock. 8 | (priority-donate-sema) Thread L downed semaphore. 9 | (priority-donate-sema) Thread H acquired lock. 10 | (priority-donate-sema) Thread H finished. 11 | (priority-donate-sema) Thread M finished. 12 | (priority-donate-sema) Thread L finished. 13 | (priority-donate-sema) Main thread finished. 14 | (priority-donate-sema) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/threads/priority-preempt.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (priority-preempt) begin 7 | (priority-preempt) Thread high-priority iteration 0 8 | (priority-preempt) Thread high-priority iteration 1 9 | (priority-preempt) Thread high-priority iteration 2 10 | (priority-preempt) Thread high-priority iteration 3 11 | (priority-preempt) Thread high-priority iteration 4 12 | (priority-preempt) Thread high-priority done! 13 | (priority-preempt) The high-priority thread should have already completed. 14 | (priority-preempt) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/Grading: -------------------------------------------------------------------------------- 1 | # Percentage of the testing point total designated for each set of 2 | # tests. 3 | 4 | # This project is primarily about implementing system calls. 5 | # If you do so properly, the base file system functionality 6 | # should come "for free". Thus, the points emphasis below. 7 | 8 | 35% tests/userprog/Rubric.functionality 9 | 25% tests/userprog/Rubric.robustness 10 | 10% tests/userprog/no-vm/Rubric 11 | 30% tests/filesys/base/Rubric 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/args-dbl-space.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (args) begin 7 | (args) argc = 3 8 | (args) argv[0] = 'args-dbl-space' 9 | (args) argv[1] = 'two' 10 | (args) argv[2] = 'spaces!' 11 | (args) argv[3] = null 12 | (args) end 13 | args-dbl-space: exit(0) 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/args-many.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (args) begin 7 | (args) argc = 23 8 | (args) argv[0] = 'args-many' 9 | (args) argv[1] = 'a' 10 | (args) argv[2] = 'b' 11 | (args) argv[3] = 'c' 12 | (args) argv[4] = 'd' 13 | (args) argv[5] = 'e' 14 | (args) argv[6] = 'f' 15 | (args) argv[7] = 'g' 16 | (args) argv[8] = 'h' 17 | (args) argv[9] = 'i' 18 | (args) argv[10] = 'j' 19 | (args) argv[11] = 'k' 20 | (args) argv[12] = 'l' 21 | (args) argv[13] = 'm' 22 | (args) argv[14] = 'n' 23 | (args) argv[15] = 'o' 24 | (args) argv[16] = 'p' 25 | (args) argv[17] = 'q' 26 | (args) argv[18] = 'r' 27 | (args) argv[19] = 's' 28 | (args) argv[20] = 't' 29 | (args) argv[21] = 'u' 30 | (args) argv[22] = 'v' 31 | (args) argv[23] = null 32 | (args) end 33 | args-many: exit(0) 34 | EOF 35 | pass; 36 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/args-multiple.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (args) begin 7 | (args) argc = 5 8 | (args) argv[0] = 'args-multiple' 9 | (args) argv[1] = 'some' 10 | (args) argv[2] = 'arguments' 11 | (args) argv[3] = 'for' 12 | (args) argv[4] = 'you!' 13 | (args) argv[5] = null 14 | (args) end 15 | args-multiple: exit(0) 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/args-none.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (args) begin 7 | (args) argc = 1 8 | (args) argv[0] = 'args-none' 9 | (args) argv[1] = null 10 | (args) end 11 | args-none: exit(0) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/args-single.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (args) begin 7 | (args) argc = 2 8 | (args) argv[0] = 'args-single' 9 | (args) argv[1] = 'onearg' 10 | (args) argv[2] = null 11 | (args) end 12 | args-single: exit(0) 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/args.c: -------------------------------------------------------------------------------- 1 | /* Prints the command-line arguments. 2 | This program is used for all of the args-* tests. Grading is 3 | done differently for each of the args-* tests based on the 4 | output. */ 5 | 6 | #include "tests/lib.h" 7 | 8 | int 9 | main (int argc, char *argv[]) 10 | { 11 | int i; 12 | 13 | test_name = "args"; 14 | 15 | msg ("begin"); 16 | msg ("argc = %d", argc); 17 | for (i = 0; i <= argc; i++) 18 | if (argv[i] != NULL) 19 | msg ("argv[%d] = '%s'", i, argv[i]); 20 | else 21 | msg ("argv[%d] = null", i); 22 | msg ("end"); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-jump.c: -------------------------------------------------------------------------------- 1 | /* This program attempts to execute code at address 0, which is not mapped. 2 | This should terminate the process with a -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | typedef int (* volatile functionptr)(void); 8 | 9 | void 10 | test_main (void) 11 | { 12 | functionptr fp = NULL; 13 | msg ("Congratulations - you have successfully called NULL: %d", 14 | fp()); 15 | fail ("should have exited with -1"); 16 | } 17 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-jump.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (bad-jump) begin 7 | bad-jump: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-jump2.c: -------------------------------------------------------------------------------- 1 | /* This program attempts to execute code at a kernel virtual address. 2 | This should terminate the process with a -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | msg ("Congratulations - you have successfully called kernel code: %d", 11 | ((int (*)(void))0xC0000000)()); 12 | fail ("should have exited with -1"); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-jump2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (bad-jump2) begin 7 | bad-jump2: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-read.c: -------------------------------------------------------------------------------- 1 | /* This program attempts to read memory at an address that is not mapped. 2 | This should terminate the process with a -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | msg ("Congratulations - you have successfully dereferenced NULL: %d", 11 | *(volatile int *) NULL); 12 | fail ("should have exited with -1"); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-read.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (bad-read) begin 7 | bad-read: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-read2.c: -------------------------------------------------------------------------------- 1 | /* This program attempts to read kernel memory. 2 | This should terminate the process with a -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | msg ("Congratulations - you have successfully read kernel memory: %d", 11 | *(int *)0xC0000000); 12 | fail ("should have exited with -1"); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-read2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (bad-read2) begin 7 | bad-read2: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-write.c: -------------------------------------------------------------------------------- 1 | /* This program attempts to write to memory at an address that is not mapped. 2 | This should terminate the process with a -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | *(volatile int *)NULL = 42; 11 | fail ("should have exited with -1"); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-write.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (bad-write) begin 7 | bad-write: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-write2.c: -------------------------------------------------------------------------------- 1 | /* This program attempts to write to kernel memory. 2 | This should terminate the process with a -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | *(int *)0xC0000000 = 42; 11 | fail ("should have exited with -1"); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/bad-write2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (bad-write2) begin 7 | bad-write2: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/boundary.c: -------------------------------------------------------------------------------- 1 | /* Utility function for tests that try to break system calls by 2 | passing them data that crosses from one virtual page to 3 | another. */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "tests/userprog/boundary.h" 9 | 10 | static char dst[8192]; 11 | 12 | /* Returns the beginning of a page. There are at least 2048 13 | modifiable bytes on either side of the pointer returned. */ 14 | void * 15 | get_boundary_area (void) 16 | { 17 | char *p = (char *) ROUND_UP ((uintptr_t) dst, 4096); 18 | if (p - dst < 2048) 19 | p += 4096; 20 | return p; 21 | } 22 | 23 | /* Returns a copy of SRC split across the boundary between two 24 | pages. */ 25 | char * 26 | copy_string_across_boundary (const char *src) 27 | { 28 | char *p = get_boundary_area (); 29 | p -= strlen (src) < 4096 ? strlen (src) / 2 : 4096; 30 | strlcpy (p, src, 4096); 31 | return p; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/boundary.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_USERPROG_BOUNDARY_H 2 | #define TESTS_USERPROG_BOUNDARY_H 3 | 4 | void *get_boundary_area (void); 5 | char *copy_string_across_boundary (const char *); 6 | 7 | #endif /* tests/userprog/boundary.h */ 8 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/child-bad.c: -------------------------------------------------------------------------------- 1 | /* Child process run by wait-killed test. 2 | Sets the stack pointer (%esp) to an invalid value and invokes 3 | a system call, which should then terminate the process with a 4 | -1 exit code. */ 5 | 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | asm volatile ("movl $0x20101234, %esp; int $0x30"); 13 | fail ("should have exited with -1"); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/child-close.c: -------------------------------------------------------------------------------- 1 | /* Child process run by multi-child-fd test. 2 | 3 | Attempts to close the file descriptor passed as the first 4 | command-line argument. This is invalid, because file 5 | descriptors are not inherited in Pintos. Two results are 6 | allowed: either the system call should return without taking 7 | any action, or the kernel should terminate the process with a 8 | -1 exit code. */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "tests/lib.h" 15 | 16 | const char *test_name = "child-close"; 17 | 18 | int 19 | main (int argc UNUSED, char *argv[]) 20 | { 21 | msg ("begin"); 22 | if (!isdigit (*argv[1])) 23 | fail ("bad command-line arguments"); 24 | close (atoi (argv[1])); 25 | msg ("end"); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/child-simple.c: -------------------------------------------------------------------------------- 1 | /* Child process run by exec-multiple, exec-one, wait-simple, and 2 | wait-twice tests. 3 | Just prints a single message and terminates. */ 4 | 5 | #include 6 | #include "tests/lib.h" 7 | 8 | const char *test_name = "child-simple"; 9 | 10 | int 11 | main (void) 12 | { 13 | msg ("run"); 14 | return 81; 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-bad-fd.c: -------------------------------------------------------------------------------- 1 | /* Tries to close an invalid fd, which must either fail silently 2 | or terminate with exit code -1. */ 3 | 4 | #include 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | close (0x20101234); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-bad-fd.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (close-bad-fd) begin 7 | (close-bad-fd) end 8 | close-bad-fd: exit(0) 9 | EOF 10 | (close-bad-fd) begin 11 | close-bad-fd: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-normal.c: -------------------------------------------------------------------------------- 1 | /* Opens a file and then closes it. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle; 11 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 12 | msg ("close \"sample.txt\""); 13 | close (handle); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-normal.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (close-normal) begin 7 | (close-normal) open "sample.txt" 8 | (close-normal) close "sample.txt" 9 | (close-normal) end 10 | close-normal: exit(0) 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-stdin.c: -------------------------------------------------------------------------------- 1 | /* Tries to close the keyboard input stream, which must either 2 | fail silently or terminate with exit code -1. */ 3 | 4 | #include 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | close (0); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-stdin.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (close-stdin) begin 7 | (close-stdin) end 8 | close-stdin: exit(0) 9 | EOF 10 | (close-stdin) begin 11 | close-stdin: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-stdout.c: -------------------------------------------------------------------------------- 1 | /* Tries to close the console output stream, which must either 2 | fail silently or terminate with exit code -1. */ 3 | 4 | #include 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | close (1); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-stdout.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (close-stdout) begin 7 | (close-stdout) end 8 | close-stdout: exit(0) 9 | EOF 10 | (close-stdout) begin 11 | close-stdout: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-twice.c: -------------------------------------------------------------------------------- 1 | /* Opens a file and then tries to close it twice. The second 2 | close must either fail silently or terminate with exit code 3 | -1. */ 4 | 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | int handle; 13 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 14 | msg ("close \"sample.txt\""); 15 | close (handle); 16 | msg ("close \"sample.txt\" again"); 17 | close (handle); 18 | } 19 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/close-twice.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (close-twice) begin 7 | (close-twice) open "sample.txt" 8 | (close-twice) close "sample.txt" 9 | (close-twice) close "sample.txt" again 10 | (close-twice) end 11 | close-twice: exit(0) 12 | EOF 13 | (close-twice) begin 14 | (close-twice) open "sample.txt" 15 | (close-twice) close "sample.txt" 16 | (close-twice) close "sample.txt" again 17 | close-twice: exit(-1) 18 | EOF 19 | pass; 20 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-bad-ptr.c: -------------------------------------------------------------------------------- 1 | /* Passes a bad pointer to the create system call, 2 | which must cause the process to be terminated with exit code 3 | -1. */ 4 | 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | msg ("create(0x20101234): %d", create ((char *) 0x20101234, 0)); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-bad-ptr.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (create-bad-ptr) begin 7 | create-bad-ptr: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-bound.c: -------------------------------------------------------------------------------- 1 | /* Opens a file whose name spans the boundary between two pages. 2 | This is valid, so it must succeed. */ 3 | 4 | #include 5 | #include "tests/userprog/boundary.h" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | msg ("create(\"quux.dat\"): %d", 13 | create (copy_string_across_boundary ("quux.dat"), 0)); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-bound.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (create-bound) begin 7 | (create-bound) create("quux.dat"): 1 8 | (create-bound) end 9 | create-bound: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-empty.c: -------------------------------------------------------------------------------- 1 | /* Tries to create a file with the empty string as its name. */ 2 | 3 | #include "tests/lib.h" 4 | #include "tests/main.h" 5 | 6 | void 7 | test_main (void) 8 | { 9 | msg ("create(\"\"): %d", create ("", 0)); 10 | } 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-empty.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (create-empty) begin 7 | (create-empty) create(""): 0 8 | (create-empty) end 9 | create-empty: exit(0) 10 | EOF 11 | (create-empty) begin 12 | create-empty: exit(-1) 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-exists.c: -------------------------------------------------------------------------------- 1 | /* Verifies that trying to create a file under a name that 2 | already exists will fail. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | CHECK (create ("quux.dat", 0), "create quux.dat"); 12 | CHECK (create ("warble.dat", 0), "create warble.dat"); 13 | CHECK (!create ("quux.dat", 0), "try to re-create quux.dat"); 14 | CHECK (create ("baffle.dat", 0), "create baffle.dat"); 15 | CHECK (!create ("warble.dat", 0), "try to re-create quux.dat"); 16 | } 17 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-exists.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (create-exists) begin 7 | (create-exists) create quux.dat 8 | (create-exists) create warble.dat 9 | (create-exists) try to re-create quux.dat 10 | (create-exists) create baffle.dat 11 | (create-exists) try to re-create quux.dat 12 | (create-exists) end 13 | create-exists: exit(0) 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-long.c: -------------------------------------------------------------------------------- 1 | /* Tries to create a file with a name that is much too long, 2 | which must fail. */ 3 | 4 | #include 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | static char name[512]; 13 | memset (name, 'x', sizeof name); 14 | name[sizeof name - 1] = '\0'; 15 | 16 | msg ("create(\"x...\"): %d", create (name, 0)); 17 | } 18 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-long.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (create-long) begin 7 | (create-long) create("x..."): 0 8 | (create-long) end 9 | create-long: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-normal.c: -------------------------------------------------------------------------------- 1 | /* Creates an ordinary empty file. */ 2 | 3 | #include "tests/lib.h" 4 | #include "tests/main.h" 5 | 6 | void 7 | test_main (void) 8 | { 9 | CHECK (create ("quux.dat", 0), "create quux.dat"); 10 | } 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-normal.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (create-normal) begin 7 | (create-normal) create quux.dat 8 | (create-normal) end 9 | create-normal: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-null.c: -------------------------------------------------------------------------------- 1 | /* Tries to create a file with the null pointer as its name. 2 | The process must be terminated with exit code -1. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | msg ("create(NULL): %d", create (NULL, 0)); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/create-null.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (create-null) begin 7 | create-null: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-arg.c: -------------------------------------------------------------------------------- 1 | /* Tests argument passing to child processes. */ 2 | 3 | #include 4 | #include "tests/main.h" 5 | 6 | void 7 | test_main (void) 8 | { 9 | wait (exec ("child-args childarg")); 10 | } 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-arg.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (exec-arg) begin 7 | (args) begin 8 | (args) argc = 2 9 | (args) argv[0] = 'child-args' 10 | (args) argv[1] = 'childarg' 11 | (args) argv[2] = null 12 | (args) end 13 | child-args: exit(0) 14 | (exec-arg) end 15 | exec-arg: exit(0) 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-bad-ptr.c: -------------------------------------------------------------------------------- 1 | /* Passes an invalid pointer to the exec system call. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | exec ((char *) 0x20101234); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-bad-ptr.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (exec-bad-ptr) begin 7 | (exec-bad-ptr) end 8 | exec-bad-ptr: exit(0) 9 | EOF 10 | (exec-bad-ptr) begin 11 | exec-bad-ptr: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-missing.c: -------------------------------------------------------------------------------- 1 | /* Tries to execute a nonexistent process. 2 | The exec system call must return -1. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | msg ("exec(\"no-such-file\"): %d", exec ("no-such-file")); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-missing.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF', <<'EOF', <<'EOF']); 6 | (exec-missing) begin 7 | load: no-such-file: open failed 8 | (exec-missing) exec("no-such-file"): -1 9 | (exec-missing) end 10 | exec-missing: exit(0) 11 | EOF 12 | (exec-missing) begin 13 | (exec-missing) exec("no-such-file"): -1 14 | (exec-missing) end 15 | exec-missing: exit(0) 16 | EOF 17 | (exec-missing) begin 18 | load: no-such-file: open failed 19 | no-such-file: exit(-1) 20 | (exec-missing) exec("no-such-file"): -1 21 | (exec-missing) end 22 | exec-missing: exit(0) 23 | EOF 24 | (exec-missing) begin 25 | load: no-such-file: open failed 26 | (exec-missing) exec("no-such-file"): -1 27 | no-such-file: exit(-1) 28 | (exec-missing) end 29 | exec-missing: exit(0) 30 | EOF 31 | pass; 32 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-multiple.c: -------------------------------------------------------------------------------- 1 | /* Executes and waits for multiple child processes. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | wait (exec ("child-simple")); 11 | wait (exec ("child-simple")); 12 | wait (exec ("child-simple")); 13 | wait (exec ("child-simple")); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-multiple.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (exec-multiple) begin 7 | (child-simple) run 8 | child-simple: exit(81) 9 | (child-simple) run 10 | child-simple: exit(81) 11 | (child-simple) run 12 | child-simple: exit(81) 13 | (child-simple) run 14 | child-simple: exit(81) 15 | (exec-multiple) end 16 | exec-multiple: exit(0) 17 | EOF 18 | pass; 19 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-once.c: -------------------------------------------------------------------------------- 1 | /* Executes and waits for a single child process. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | wait (exec ("child-simple")); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exec-once.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (exec-once) begin 7 | (child-simple) run 8 | child-simple: exit(81) 9 | (exec-once) end 10 | exec-once: exit(0) 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exit.c: -------------------------------------------------------------------------------- 1 | /* Tests the exit system call. */ 2 | 3 | #include "tests/lib.h" 4 | #include "tests/main.h" 5 | 6 | void 7 | test_main (void) 8 | { 9 | exit (57); 10 | fail ("should have called exit(57)"); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/exit.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (exit) begin 7 | exit: exit(57) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/filesize.c: -------------------------------------------------------------------------------- 1 | /* Checks filesize */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | create("example.txt", 128); 11 | int fd = open("example.txt"); 12 | 13 | if (filesize(fd) != 128) { 14 | fail("failed to return the right filesize"); 15 | } 16 | 17 | 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/filesize.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (filesize) begin 7 | (filesize) end 8 | filesize: exit(0) 9 | EOF 10 | pass; -------------------------------------------------------------------------------- /pintos/src/tests/userprog/halt.c: -------------------------------------------------------------------------------- 1 | /* Tests the halt system call. */ 2 | 3 | #include "tests/lib.h" 4 | #include "tests/main.h" 5 | 6 | void 7 | test_main (void) 8 | { 9 | halt (); 10 | fail ("should have halted"); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/halt.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | 6 | our ($test); 7 | my (@output) = read_text_file ("$test.output"); 8 | 9 | common_checks ("run", @output); 10 | 11 | fail "missing 'begin' message\n" 12 | if !grep ($_ eq '(halt) begin', @output); 13 | fail "found 'fail' message--halt didn't really halt\n" 14 | if grep ($_ eq '(halt) fail', @output); 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/iloveos.c: -------------------------------------------------------------------------------- 1 | /* Tests the null syscall */ 2 | 3 | #include "tests/lib.h" 4 | #include "tests/main.h" 5 | #include 6 | 7 | void 8 | test_main (void) 9 | { 10 | char *msg = "I love CS162\n"; 11 | write(1, msg, strlen(msg)); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/iloveos.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (iloveos) begin 7 | I love CS162 8 | (iloveos) end 9 | iloveos: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/lib/.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/lib/user/.dummy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jangsoo/PintosOS/0cfab4a123a9e8a21a102e4da11916ff61d12df0/pintos/src/tests/userprog/lib/user/.dummy -------------------------------------------------------------------------------- /pintos/src/tests/userprog/lib/user/.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/multi-child-fd.c: -------------------------------------------------------------------------------- 1 | /* Opens a file and then runs a subprocess that tries to close 2 | the file. (Pintos does not have inheritance of file handles, 3 | so this must fail.) The parent process then attempts to use 4 | the file handle, which must succeed. */ 5 | 6 | #include 7 | #include 8 | #include "tests/userprog/sample.inc" 9 | #include "tests/lib.h" 10 | #include "tests/main.h" 11 | 12 | void 13 | test_main (void) 14 | { 15 | char child_cmd[128]; 16 | int handle; 17 | 18 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 19 | 20 | snprintf (child_cmd, sizeof child_cmd, "child-close %d", handle); 21 | 22 | msg ("wait(exec()) = %d", wait (exec (child_cmd))); 23 | 24 | check_file_handle (handle, "sample.txt", sample, sizeof sample - 1); 25 | } 26 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/multi-child-fd.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (multi-child-fd) begin 7 | (multi-child-fd) open "sample.txt" 8 | (child-close) begin 9 | (child-close) end 10 | child-close: exit(0) 11 | (multi-child-fd) wait(exec()) = 0 12 | (multi-child-fd) verified contents of "sample.txt" 13 | (multi-child-fd) end 14 | multi-child-fd: exit(0) 15 | EOF 16 | (multi-child-fd) begin 17 | (multi-child-fd) open "sample.txt" 18 | (child-close) begin 19 | child-close: exit(-1) 20 | (multi-child-fd) wait(exec()) = -1 21 | (multi-child-fd) verified contents of "sample.txt" 22 | (multi-child-fd) end 23 | multi-child-fd: exit(0) 24 | EOF 25 | pass; 26 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/multi-recurse.c: -------------------------------------------------------------------------------- 1 | /* Executes itself recursively to the depth indicated by the 2 | first command-line argument. */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "tests/lib.h" 9 | 10 | const char *test_name = "multi-recurse"; 11 | 12 | int 13 | main (int argc UNUSED, char *argv[]) 14 | { 15 | int n = atoi (argv[1]); 16 | 17 | msg ("begin %d", n); 18 | if (n != 0) 19 | { 20 | char child_cmd[128]; 21 | pid_t child_pid; 22 | int code; 23 | 24 | snprintf (child_cmd, sizeof child_cmd, "multi-recurse %d", n - 1); 25 | CHECK ((child_pid = exec (child_cmd)) != -1, "exec(\"%s\")", child_cmd); 26 | 27 | code = wait (child_pid); 28 | if (code != n - 1) 29 | fail ("wait(exec(\"%s\")) returned %d", child_cmd, code); 30 | } 31 | 32 | msg ("end %d", n); 33 | return n; 34 | } 35 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/no-vm/Make.tests: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | tests/userprog/no-vm_TESTS = tests/userprog/no-vm/multi-oom 4 | tests/userprog/no-vm_PROGS = $(tests/userprog/no-vm_TESTS) 5 | tests/userprog/no-vm/multi-oom_SRC = tests/userprog/no-vm/multi-oom.c \ 6 | tests/lib.c 7 | 8 | tests/userprog/no-vm/multi-oom.output: TIMEOUT = 360 9 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/no-vm/Rubric: -------------------------------------------------------------------------------- 1 | Functionality of features that VM might break: 2 | 3 | 1 multi-oom 4 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/no-vm/multi-oom.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (multi-oom) begin 7 | (multi-oom) success. program forked 10 times. 8 | (multi-oom) end 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-bad-ptr.c: -------------------------------------------------------------------------------- 1 | /* Passes an invalid pointer to the open system call. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | msg ("open(0x20101234): %d", open ((char *) 0x20101234)); 12 | fail ("should have called exit(-1)"); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-bad-ptr.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (open-bad-ptr) begin 7 | (open-bad-ptr) end 8 | open-bad-ptr: exit(0) 9 | EOF 10 | (open-bad-ptr) begin 11 | open-bad-ptr: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-boundary.c: -------------------------------------------------------------------------------- 1 | /* Creates a file whose name spans the boundary between two pages. 2 | This is valid, so it must succeed. */ 3 | 4 | #include 5 | #include "tests/userprog/boundary.h" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | CHECK (open (copy_string_across_boundary ("sample.txt")) > 1, 13 | "open \"sample.txt\""); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-boundary.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (open-boundary) begin 7 | (open-boundary) open "sample.txt" 8 | (open-boundary) end 9 | open-boundary: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-empty.c: -------------------------------------------------------------------------------- 1 | /* Tries to open a file with the empty string as its name. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle = open (""); 11 | if (handle != -1) 12 | fail ("open() returned %d instead of -1", handle); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-empty.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (open-empty) begin 7 | (open-empty) end 8 | open-empty: exit(0) 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-missing.c: -------------------------------------------------------------------------------- 1 | /* Tries to open a nonexistent file. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle = open ("no-such-file"); 11 | if (handle != -1) 12 | fail ("open() returned %d", handle); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-missing.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (open-missing) begin 7 | (open-missing) end 8 | open-missing: exit(0) 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-normal.c: -------------------------------------------------------------------------------- 1 | /* Open a file. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle = open ("sample.txt"); 11 | if (handle < 2) 12 | fail ("open() returned %d", handle); 13 | } 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-normal.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (open-normal) begin 7 | (open-normal) end 8 | open-normal: exit(0) 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-null.c: -------------------------------------------------------------------------------- 1 | /* Tries to open a file with the null pointer as its name. 2 | The process must be terminated with exit code -1. */ 3 | 4 | #include 5 | #include 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | open (NULL); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-null.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (open-null) begin 7 | (open-null) end 8 | open-null: exit(0) 9 | EOF 10 | (open-null) begin 11 | open-null: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-twice.c: -------------------------------------------------------------------------------- 1 | /* Tries to open the same file twice, 2 | which must succeed and must return a different file descriptor 3 | in each case. */ 4 | 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | int h1 = open ("sample.txt"); 13 | int h2 = open ("sample.txt"); 14 | 15 | CHECK ((h1 = open ("sample.txt")) > 1, "open \"sample.txt\" once"); 16 | CHECK ((h2 = open ("sample.txt")) > 1, "open \"sample.txt\" again"); 17 | if (h1 == h2) 18 | fail ("open() returned %d both times", h1); 19 | } 20 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/open-twice.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (open-twice) begin 7 | (open-twice) open "sample.txt" once 8 | (open-twice) open "sample.txt" again 9 | (open-twice) end 10 | open-twice: exit(0) 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/practice.c: -------------------------------------------------------------------------------- 1 | /* Tests the practice syscall */ 2 | 3 | #include "tests/lib.h" 4 | #include "tests/main.h" 5 | #include 6 | 7 | void 8 | test_main (void) 9 | { 10 | int i = practice(5); 11 | if (i != 6) { 12 | fail("Practice syscall failed because i was not 6 as expected\n"); 13 | } 14 | i = practice(10); 15 | if (i != 11) { 16 | fail("Practice syscall failed because i was not 11 as expected\n"); 17 | } 18 | printf("practice\n"); 19 | } 20 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/practice.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (practice) begin 7 | practice 8 | (practice) end 9 | practice: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-bad-fd.c: -------------------------------------------------------------------------------- 1 | /* Tries to read from an invalid fd, 2 | which must either fail silently or terminate the process with 3 | exit code -1. */ 4 | 5 | #include 6 | #include 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | char buf; 14 | read (0x20101234, &buf, 1); 15 | read (5, &buf, 1); 16 | read (1234, &buf, 1); 17 | read (-1, &buf, 1); 18 | read (-1024, &buf, 1); 19 | read (INT_MIN, &buf, 1); 20 | read (INT_MAX, &buf, 1); 21 | } 22 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-bad-fd.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (read-bad-fd) begin 7 | (read-bad-fd) end 8 | read-bad-fd: exit(0) 9 | EOF 10 | (read-bad-fd) begin 11 | read-bad-fd: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-bad-ptr.c: -------------------------------------------------------------------------------- 1 | /* Passes an invalid pointer to the read system call. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle; 12 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 13 | 14 | read (handle, (char *) 0xc0100000, 123); 15 | fail ("should not have survived read()"); 16 | } 17 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-bad-ptr.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (read-bad-ptr) begin 7 | (read-bad-ptr) open "sample.txt" 8 | (read-bad-ptr) end 9 | read-bad-ptr: exit(0) 10 | EOF 11 | (read-bad-ptr) begin 12 | (read-bad-ptr) open "sample.txt" 13 | read-bad-ptr: exit(-1) 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-boundary.c: -------------------------------------------------------------------------------- 1 | /* Reads data spanning two pages in virtual address space, 2 | which must succeed. */ 3 | 4 | #include 5 | #include 6 | #include "tests/userprog/boundary.h" 7 | #include "tests/userprog/sample.inc" 8 | #include "tests/lib.h" 9 | #include "tests/main.h" 10 | 11 | void 12 | test_main (void) 13 | { 14 | int handle; 15 | int byte_cnt; 16 | char *buffer; 17 | 18 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 19 | 20 | buffer = get_boundary_area () - sizeof sample / 2; 21 | byte_cnt = read (handle, buffer, sizeof sample - 1); 22 | if (byte_cnt != sizeof sample - 1) 23 | fail ("read() returned %d instead of %zu", byte_cnt, sizeof sample - 1); 24 | else if (strcmp (sample, buffer)) 25 | { 26 | msg ("expected text:\n%s", sample); 27 | msg ("text actually read:\n%s", buffer); 28 | fail ("expected text differs from actual"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-boundary.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (read-boundary) begin 7 | (read-boundary) open "sample.txt" 8 | (read-boundary) end 9 | read-boundary: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-normal.c: -------------------------------------------------------------------------------- 1 | /* Try reading a file in the most normal way. */ 2 | 3 | #include "tests/userprog/sample.inc" 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | check_file ("sample.txt", sample, sizeof sample - 1); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-normal.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (read-normal) begin 7 | (read-normal) open "sample.txt" for verification 8 | (read-normal) verified contents of "sample.txt" 9 | (read-normal) close "sample.txt" 10 | (read-normal) end 11 | read-normal: exit(0) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-stdout.c: -------------------------------------------------------------------------------- 1 | /* Try reading from fd 1 (stdout), 2 | which may just fail or terminate the process with -1 exit 3 | code. */ 4 | 5 | #include 6 | #include 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | char buf; 13 | read (STDOUT_FILENO, &buf, 1); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-stdout.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (read-stdout) begin 7 | (read-stdout) end 8 | read-stdout: exit(0) 9 | EOF 10 | (read-stdout) begin 11 | read-stdout: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-zero.c: -------------------------------------------------------------------------------- 1 | /* Try a 0-byte read, which should return 0 without reading 2 | anything. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle, byte_cnt; 12 | char buf; 13 | 14 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 15 | 16 | buf = 123; 17 | byte_cnt = read (handle, &buf, 0); 18 | if (byte_cnt != 0) 19 | fail ("read() returned %d instead of 0", byte_cnt); 20 | else if (buf != 123) 21 | fail ("0-byte read() modified buffer"); 22 | } 23 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/read-zero.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (read-zero) begin 7 | (read-zero) open "sample.txt" 8 | (read-zero) end 9 | read-zero: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/rox-child.c: -------------------------------------------------------------------------------- 1 | /* Ensure that the executable of a running process cannot be 2 | modified, even by a child process. */ 3 | 4 | #define CHILD_CNT "1" 5 | #include "tests/userprog/rox-child.inc" 6 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/rox-child.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (rox-child) begin 7 | (rox-child) open "child-rox" 8 | (rox-child) read "child-rox" 9 | (rox-child) write "child-rox" 10 | (rox-child) exec "child-rox 1" 11 | (child-rox) begin 12 | (child-rox) try to write "child-rox" 13 | (child-rox) try to write "child-rox" 14 | (child-rox) end 15 | child-rox: exit(12) 16 | (rox-child) write "child-rox" 17 | (rox-child) end 18 | rox-child: exit(0) 19 | EOF 20 | pass; 21 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/rox-multichild.c: -------------------------------------------------------------------------------- 1 | /* Ensure that the executable of a running process cannot be 2 | modified, even in the presence of multiple children. */ 3 | 4 | #define CHILD_CNT "5" 5 | #include "tests/userprog/rox-child.inc" 6 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/rox-simple.c: -------------------------------------------------------------------------------- 1 | /* Ensure that the executable of a running process cannot be 2 | modified. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle; 12 | char buffer[16]; 13 | 14 | CHECK ((handle = open ("rox-simple")) > 1, "open \"rox-simple\""); 15 | CHECK (read (handle, buffer, sizeof buffer) == (int) sizeof buffer, 16 | "read \"rox-simple\""); 17 | CHECK (write (handle, buffer, sizeof buffer) == 0, 18 | "try to write \"rox-simple\""); 19 | } 20 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/rox-simple.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (rox-simple) begin 7 | (rox-simple) open "rox-simple" 8 | (rox-simple) read "rox-simple" 9 | (rox-simple) try to write "rox-simple" 10 | (rox-simple) end 11 | rox-simple: exit(0) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sample.inc: -------------------------------------------------------------------------------- 1 | char sample[] = { 2 | "\"Amazing Electronic Fact: If you scuffed your feet long enough without\n" 3 | " touching anything, you would build up so many electrons that your\n" 4 | " finger would explode! But this is nothing to worry about unless you\n" 5 | " have carpeting.\" --Dave Barry\n" 6 | }; 7 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sample.txt: -------------------------------------------------------------------------------- 1 | "Amazing Electronic Fact: If you scuffed your feet long enough without 2 | touching anything, you would build up so many electrons that your 3 | finger would explode! But this is nothing to worry about unless you 4 | have carpeting." --Dave Barry 5 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-bad-arg.c: -------------------------------------------------------------------------------- 1 | /* Sticks a system call number (SYS_EXIT) at the very top of the 2 | stack, then invokes a system call with the stack pointer 3 | (%esp) set to its address. The process must be terminated 4 | with -1 exit code because the argument to the system call 5 | would be above the top of the user address space. */ 6 | 7 | #include 8 | #include "tests/lib.h" 9 | #include "tests/main.h" 10 | 11 | void 12 | test_main (void) 13 | { 14 | asm volatile ("movl $0xbffffffc, %%esp; movl %0, (%%esp); int $0x30" 15 | : : "i" (SYS_EXIT)); 16 | fail ("should have called exit(-1)"); 17 | } 18 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-bad-arg.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (sc-bad-arg) begin 7 | sc-bad-arg: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-bad-sp.c: -------------------------------------------------------------------------------- 1 | /* Invokes a system call with the stack pointer (%esp) set to a 2 | bad address. The process must be terminated with -1 exit 3 | code. 4 | 5 | For Project 3: The bad address lies approximately 64MB below 6 | the code segment, so there is no ambiguity that this attempt 7 | must be rejected even after stack growth is implemented. 8 | Moreover, a good stack growth heuristics should probably not 9 | grow the stack for the purpose of reading the system call 10 | number and arguments. */ 11 | 12 | #include "tests/lib.h" 13 | #include "tests/main.h" 14 | 15 | void 16 | test_main (void) 17 | { 18 | asm volatile ("movl $.-(64*1024*1024), %esp; int $0x30"); 19 | fail ("should have called exit(-1)"); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-bad-sp.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (sc-bad-sp) begin 7 | sc-bad-sp: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-boundary-2.c: -------------------------------------------------------------------------------- 1 | /* Invokes a system call with one byte of the system call's 2 | argument on a separate page from the rest of the bytes. This 3 | must work. */ 4 | 5 | #include 6 | #include "tests/userprog/boundary.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | /* Make one byte of a syscall argument hang over into a second 14 | page. */ 15 | int *p = (int *) ((char *) get_boundary_area () - 7); 16 | p[0] = SYS_EXIT; 17 | p[1] = 67; 18 | 19 | /* Invoke the system call. */ 20 | asm volatile ("movl %0, %%esp; int $0x30" : : "g" (p)); 21 | fail ("should have called exit(67)"); 22 | } 23 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-boundary-2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (sc-boundary-2) begin 7 | sc-boundary-2: exit(67) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-boundary.c: -------------------------------------------------------------------------------- 1 | /* Invokes a system call with the system call number and its 2 | argument on separate pages. This must work. */ 3 | 4 | #include 5 | #include "tests/userprog/boundary.h" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | /* Put a syscall number at the end of one page 13 | and its argument at the beginning of another. */ 14 | int *p = get_boundary_area (); 15 | p--; 16 | p[0] = SYS_EXIT; 17 | p[1] = 42; 18 | 19 | /* Invoke the system call. */ 20 | asm volatile ("movl %0, %%esp; int $0x30" : : "g" (p)); 21 | fail ("should have called exit(42)"); 22 | } 23 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/sc-boundary.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (sc-boundary) begin 7 | sc-boundary: exit(42) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/seek-tell.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (seek-tell) begin 7 | (seek-tell) filesize: 239 8 | (seek-tell) tell: 0 9 | (seek-tell) tell: 100 10 | (seek-tell) tell: 200 11 | (seek-tell) tell: 339 12 | (seek-tell) 0 bytes read 13 | (seek-tell) tell: 339 14 | (seek-tell) end 15 | seek-tell: exit(0) 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-bad-pid.c: -------------------------------------------------------------------------------- 1 | /* Waits for an invalid pid. This may fail or terminate the 2 | process with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | wait ((pid_t) 0x0c020301); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-bad-pid.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (wait-bad-pid) begin 7 | (wait-bad-pid) end 8 | wait-bad-pid: exit(0) 9 | EOF 10 | (wait-bad-pid) begin 11 | wait-bad-pid: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-killed.c: -------------------------------------------------------------------------------- 1 | /* Wait for a process that will be killed for bad behavior. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | msg ("wait(exec()) = %d", wait (exec ("child-bad"))); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-killed.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (wait-killed) begin 7 | (child-bad) begin 8 | child-bad: exit(-1) 9 | (wait-killed) wait(exec()) = -1 10 | (wait-killed) end 11 | wait-killed: exit(0) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-simple.c: -------------------------------------------------------------------------------- 1 | /* Wait for a subprocess to finish. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | msg ("wait(exec()) = %d", wait (exec ("child-simple"))); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-simple.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (wait-simple) begin 7 | (child-simple) run 8 | child-simple: exit(81) 9 | (wait-simple) wait(exec()) = 81 10 | (wait-simple) end 11 | wait-simple: exit(0) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-twice.c: -------------------------------------------------------------------------------- 1 | /* Wait for a subprocess to finish, twice. 2 | The first call must wait in the usual way and return the exit code. 3 | The second wait call must return -1 immediately. */ 4 | 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | pid_t child = exec ("child-simple"); 13 | msg ("wait(exec()) = %d", wait (child)); 14 | msg ("wait(exec()) = %d", wait (child)); 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/wait-twice.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (wait-twice) begin 7 | (child-simple) run 8 | child-simple: exit(81) 9 | (wait-twice) wait(exec()) = 81 10 | (wait-twice) wait(exec()) = -1 11 | (wait-twice) end 12 | wait-twice: exit(0) 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-bad-fd.c: -------------------------------------------------------------------------------- 1 | /* Tries to write to an invalid fd, 2 | which must either fail silently or terminate the process with 3 | exit code -1. */ 4 | 5 | #include 6 | #include 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | char buf = 123; 13 | write (0x01012342, &buf, 1); 14 | write (7, &buf, 1); 15 | write (2546, &buf, 1); 16 | write (-5, &buf, 1); 17 | write (-8192, &buf, 1); 18 | write (INT_MIN + 1, &buf, 1); 19 | write (INT_MAX - 1, &buf, 1); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-bad-fd.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (write-bad-fd) begin 7 | (write-bad-fd) end 8 | write-bad-fd: exit(0) 9 | EOF 10 | (write-bad-fd) begin 11 | write-bad-fd: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-bad-ptr.c: -------------------------------------------------------------------------------- 1 | /* Passes an invalid pointer to the write system call. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle; 12 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 13 | 14 | write (handle, (char *) 0x10123420, 123); 15 | fail ("should have exited with -1"); 16 | } 17 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-bad-ptr.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (write-bad-ptr) begin 7 | (write-bad-ptr) open "sample.txt" 8 | (write-bad-ptr) end 9 | write-bad-ptr: exit(0) 10 | EOF 11 | (write-bad-ptr) begin 12 | (write-bad-ptr) open "sample.txt" 13 | write-bad-ptr: exit(-1) 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-boundary.c: -------------------------------------------------------------------------------- 1 | /* Writes data spanning two pages in virtual address space, 2 | which must succeed. */ 3 | 4 | #include 5 | #include 6 | #include "tests/userprog/boundary.h" 7 | #include "tests/userprog/sample.inc" 8 | #include "tests/lib.h" 9 | #include "tests/main.h" 10 | 11 | void 12 | test_main (void) 13 | { 14 | int handle; 15 | int byte_cnt; 16 | char *sample_p; 17 | 18 | sample_p = copy_string_across_boundary (sample); 19 | 20 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 21 | 22 | byte_cnt = write (handle, sample_p, sizeof sample - 1); 23 | if (byte_cnt != sizeof sample - 1) 24 | fail ("write() returned %d instead of %zu", byte_cnt, sizeof sample - 1); 25 | } 26 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-boundary.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (write-boundary) begin 7 | (write-boundary) open "sample.txt" 8 | (write-boundary) end 9 | write-boundary: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-normal.c: -------------------------------------------------------------------------------- 1 | /* Try writing a file in the most normal way. */ 2 | 3 | #include 4 | #include "tests/userprog/sample.inc" 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle, byte_cnt; 12 | 13 | CHECK (create ("test.txt", sizeof sample - 1), "create \"test.txt\""); 14 | CHECK ((handle = open ("test.txt")) > 1, "open \"test.txt\""); 15 | 16 | byte_cnt = write (handle, sample, sizeof sample - 1); 17 | if (byte_cnt != sizeof sample - 1) 18 | fail ("write() returned %d instead of %zu", byte_cnt, sizeof sample - 1); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-normal.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (write-normal) begin 7 | (write-normal) create "test.txt" 8 | (write-normal) open "test.txt" 9 | (write-normal) end 10 | write-normal: exit(0) 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-stdin.c: -------------------------------------------------------------------------------- 1 | /* Try writing to fd 0 (stdin), 2 | which may just fail or terminate the process with -1 exit 3 | code. */ 4 | 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | char buf = 123; 13 | write (0, &buf, 1); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-stdin.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (write-stdin) begin 7 | (write-stdin) end 8 | write-stdin: exit(0) 9 | EOF 10 | (write-stdin) begin 11 | write-stdin: exit(-1) 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-zero.c: -------------------------------------------------------------------------------- 1 | /* Try a 0-byte write, which should return 0 without writing 2 | anything. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle, byte_cnt; 12 | char buf; 13 | 14 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 15 | 16 | buf = 123; 17 | byte_cnt = write (handle, &buf, 0); 18 | if (byte_cnt != 0) 19 | fail("write() returned %d instead of 0", byte_cnt); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/userprog/write-zero.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (write-zero) begin 7 | (write-zero) open "sample.txt" 8 | (write-zero) end 9 | write-zero: exit(0) 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/Grading: -------------------------------------------------------------------------------- 1 | # Percentage of the testing point total designated for each set of 2 | # tests. 3 | 4 | # This project is primarily about virtual memory, but all the previous 5 | # functionality should work too, and it's easy to screw it up, thus 6 | # the equal weight placed on each. 7 | 8 | 50% tests/vm/Rubric.functionality 9 | 15% tests/vm/Rubric.robustness 10 | 10% tests/userprog/Rubric.functionality 11 | 5% tests/userprog/Rubric.robustness 12 | 20% tests/filesys/base/Rubric 13 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/Rubric.functionality: -------------------------------------------------------------------------------- 1 | Functionality of virtual memory subsystem: 2 | - Test stack growth. 3 | 3 pt-grow-stack 4 | 3 pt-grow-stk-sc 5 | 3 pt-big-stk-obj 6 | 3 pt-grow-pusha 7 | 8 | - Test paging behavior. 9 | 3 page-linear 10 | 3 page-parallel 11 | 3 page-shuffle 12 | 4 page-merge-seq 13 | 4 page-merge-par 14 | 4 page-merge-mm 15 | 4 page-merge-stk 16 | 17 | - Test "mmap" system call. 18 | 2 mmap-read 19 | 2 mmap-write 20 | 2 mmap-shuffle 21 | 22 | 2 mmap-twice 23 | 24 | 2 mmap-unmap 25 | 1 mmap-exit 26 | 27 | 3 mmap-clean 28 | 29 | 2 mmap-close 30 | 2 mmap-remove 31 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/Rubric.robustness: -------------------------------------------------------------------------------- 1 | Robustness of virtual memory subsystem: 2 | - Test robustness of page table support. 3 | 2 pt-bad-addr 4 | 3 pt-bad-read 5 | 2 pt-write-code 6 | 3 pt-write-code2 7 | 4 pt-grow-bad 8 | 9 | - Test robustness of "mmap" system call. 10 | 1 mmap-bad-fd 11 | 1 mmap-inherit 12 | 1 mmap-null 13 | 1 mmap-zero 14 | 15 | 2 mmap-misalign 16 | 17 | 2 mmap-over-code 18 | 2 mmap-over-data 19 | 2 mmap-over-stk 20 | 2 mmap-overlap 21 | 22 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/child-inherit.c: -------------------------------------------------------------------------------- 1 | /* Child process for mmap-inherit test. 2 | Tries to write to a mapping present in the parent. 3 | The process must be terminated with -1 exit code. */ 4 | 5 | #include 6 | #include "tests/vm/sample.inc" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | memset ((char *) 0x54321000, 0, 4096); 14 | fail ("child can modify parent's memory mappings"); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/child-linear.c: -------------------------------------------------------------------------------- 1 | /* Child process of page-parallel. 2 | Encrypts 1 MB of zeros, then decrypts it, and ensures that 3 | the zeros are back. */ 4 | 5 | #include 6 | #include "tests/arc4.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | const char *test_name = "child-linear"; 11 | 12 | #define SIZE (1024 * 1024) 13 | static char buf[SIZE]; 14 | 15 | int 16 | main (int argc, char *argv[]) 17 | { 18 | const char *key = argv[argc - 1]; 19 | struct arc4 arc4; 20 | size_t i; 21 | 22 | /* Encrypt zeros. */ 23 | arc4_init (&arc4, key, strlen (key)); 24 | arc4_crypt (&arc4, buf, SIZE); 25 | 26 | /* Decrypt back to zeros. */ 27 | arc4_init (&arc4, key, strlen (key)); 28 | arc4_crypt (&arc4, buf, SIZE); 29 | 30 | /* Check that it's all zeros. */ 31 | for (i = 0; i < SIZE; i++) 32 | if (buf[i] != '\0') 33 | fail ("byte %zu != 0", i); 34 | 35 | return 0x42; 36 | } 37 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/child-mm-wrt.c: -------------------------------------------------------------------------------- 1 | /* Child process of mmap-exit. 2 | Mmaps a file and writes to it via the mmap'ing, then exits 3 | without calling munmap. The data in the mapped region must be 4 | written out at program termination. */ 5 | 6 | #include 7 | #include 8 | #include "tests/vm/sample.inc" 9 | #include "tests/lib.h" 10 | #include "tests/main.h" 11 | 12 | #define ACTUAL ((void *) 0x10000000) 13 | 14 | void 15 | test_main (void) 16 | { 17 | int handle; 18 | 19 | CHECK (create ("sample.txt", sizeof sample), "create \"sample.txt\""); 20 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 21 | CHECK (mmap (handle, ACTUAL) != MAP_FAILED, "mmap \"sample.txt\""); 22 | memcpy (ACTUAL, sample, sizeof sample); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/child-qsort-mm.c: -------------------------------------------------------------------------------- 1 | /* Mmaps a 128 kB file "sorts" the bytes in it, using quick sort, 2 | a multi-pass divide and conquer algorithm. */ 3 | 4 | #include 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | #include "tests/vm/qsort.h" 9 | 10 | const char *test_name = "child-qsort-mm"; 11 | 12 | int 13 | main (int argc UNUSED, char *argv[]) 14 | { 15 | int handle; 16 | unsigned char *p = (unsigned char *) 0x10000000; 17 | 18 | quiet = true; 19 | 20 | CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]); 21 | CHECK (mmap (handle, p) != MAP_FAILED, "mmap \"%s\"", argv[1]); 22 | qsort_bytes (p, 1024 * 128); 23 | 24 | return 80; 25 | } 26 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/child-qsort.c: -------------------------------------------------------------------------------- 1 | /* Reads a 128 kB file onto the stack and "sorts" the bytes in 2 | it, using quick sort, a multi-pass divide and conquer 3 | algorithm. The sorted data is written back to the same file 4 | in-place. */ 5 | 6 | #include 7 | #include 8 | #include "tests/lib.h" 9 | #include "tests/main.h" 10 | #include "tests/vm/qsort.h" 11 | 12 | const char *test_name = "child-qsort"; 13 | 14 | int 15 | main (int argc UNUSED, char *argv[]) 16 | { 17 | int handle; 18 | unsigned char buf[128 * 1024]; 19 | size_t size; 20 | 21 | quiet = true; 22 | 23 | CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]); 24 | 25 | size = read (handle, buf, sizeof buf); 26 | qsort_bytes (buf, sizeof buf); 27 | seek (handle, 0); 28 | write (handle, buf, size); 29 | close (handle); 30 | 31 | return 72; 32 | } 33 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-bad-fd.c: -------------------------------------------------------------------------------- 1 | /* Tries to mmap an invalid fd, 2 | which must either fail silently or terminate the process with 3 | exit code -1. */ 4 | 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | CHECK (mmap (0x5678, (void *) 0x10000000) == MAP_FAILED, 13 | "try to mmap invalid fd"); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-bad-fd.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF', <<'EOF']); 6 | (mmap-bad-fd) begin 7 | (mmap-bad-fd) try to mmap invalid fd 8 | (mmap-bad-fd) end 9 | mmap-bad-fd: exit(0) 10 | EOF 11 | (mmap-bad-fd) begin 12 | (mmap-bad-fd) try to mmap invalid fd 13 | mmap-bad-fd: exit(-1) 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-clean.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-clean) begin 7 | (mmap-clean) open "sample.txt" 8 | (mmap-clean) mmap "sample.txt" 9 | (mmap-clean) write "sample.txt" 10 | (mmap-clean) munmap "sample.txt" 11 | (mmap-clean) seek "sample.txt" 12 | (mmap-clean) read "sample.txt" 13 | (mmap-clean) file change was retained after munmap 14 | (mmap-clean) end 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-close.c: -------------------------------------------------------------------------------- 1 | /* Verifies that memory mappings persist after file close. */ 2 | 3 | #include 4 | #include 5 | #include "tests/vm/sample.inc" 6 | #include "tests/arc4.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | #define ACTUAL ((void *) 0x10000000) 11 | 12 | void 13 | test_main (void) 14 | { 15 | int handle; 16 | mapid_t map; 17 | 18 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 19 | CHECK ((map = mmap (handle, ACTUAL)) != MAP_FAILED, "mmap \"sample.txt\""); 20 | 21 | close (handle); 22 | 23 | if (memcmp (ACTUAL, sample, strlen (sample))) 24 | fail ("read of mmap'd file reported bad data"); 25 | 26 | munmap (map); 27 | } 28 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-close.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-close) begin 7 | (mmap-close) open "sample.txt" 8 | (mmap-close) mmap "sample.txt" 9 | (mmap-close) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-exit.c: -------------------------------------------------------------------------------- 1 | /* Executes child-mm-wrt and verifies that the writes that should 2 | have occurred really did. */ 3 | 4 | #include 5 | #include "tests/vm/sample.inc" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | pid_t child; 13 | 14 | /* Make child write file. */ 15 | quiet = true; 16 | CHECK ((child = exec ("child-mm-wrt")) != -1, "exec \"child-mm-wrt\""); 17 | CHECK (wait (child) == 0, "wait for child (should return 0)"); 18 | quiet = false; 19 | 20 | /* Check file contents. */ 21 | check_file ("sample.txt", sample, sizeof sample); 22 | } 23 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-exit.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-exit) begin 7 | (child-mm-wrt) begin 8 | (child-mm-wrt) create "sample.txt" 9 | (child-mm-wrt) open "sample.txt" 10 | (child-mm-wrt) mmap "sample.txt" 11 | (child-mm-wrt) end 12 | (mmap-exit) open "sample.txt" for verification 13 | (mmap-exit) verified contents of "sample.txt" 14 | (mmap-exit) close "sample.txt" 15 | (mmap-exit) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-inherit.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (mmap-inherit) begin 7 | (mmap-inherit) open "sample.txt" 8 | (mmap-inherit) mmap "sample.txt" 9 | (mmap-inherit) exec "child-inherit" 10 | (child-inherit) begin 11 | child-inherit: exit(-1) 12 | (mmap-inherit) checking that mmap'd file still has same data 13 | (mmap-inherit) end 14 | mmap-inherit: exit(0) 15 | EOF 16 | pass; 17 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-misalign.c: -------------------------------------------------------------------------------- 1 | /* Verifies that misaligned memory mappings are disallowed. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle; 11 | 12 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 13 | CHECK (mmap (handle, (void *) 0x10001234) == MAP_FAILED, 14 | "try to mmap at misaligned address"); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-misalign.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-misalign) begin 7 | (mmap-misalign) open "sample.txt" 8 | (mmap-misalign) try to mmap at misaligned address 9 | (mmap-misalign) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-null.c: -------------------------------------------------------------------------------- 1 | /* Verifies that memory mappings at address 0 are disallowed. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle; 11 | 12 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 13 | CHECK (mmap (handle, NULL) == MAP_FAILED, "try to mmap at address 0"); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-null.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-null) begin 7 | (mmap-null) open "sample.txt" 8 | (mmap-null) try to mmap at address 0 9 | (mmap-null) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-over-code.c: -------------------------------------------------------------------------------- 1 | /* Verifies that mapping over the code segment is disallowed. */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | uintptr_t test_main_page = ROUND_DOWN ((uintptr_t) test_main, 4096); 13 | int handle; 14 | 15 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 16 | CHECK (mmap (handle, (void *) test_main_page) == MAP_FAILED, 17 | "try to mmap over code segment"); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-over-code.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-over-code) begin 7 | (mmap-over-code) open "sample.txt" 8 | (mmap-over-code) try to mmap over code segment 9 | (mmap-over-code) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-over-data.c: -------------------------------------------------------------------------------- 1 | /* Verifies that mapping over the data segment is disallowed. */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | static char x; 10 | 11 | void 12 | test_main (void) 13 | { 14 | uintptr_t x_page = ROUND_DOWN ((uintptr_t) &x, 4096); 15 | int handle; 16 | 17 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 18 | CHECK (mmap (handle, (void *) x_page) == MAP_FAILED, 19 | "try to mmap over data segment"); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-over-data.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-over-data) begin 7 | (mmap-over-data) open "sample.txt" 8 | (mmap-over-data) try to mmap over data segment 9 | (mmap-over-data) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-over-stk.c: -------------------------------------------------------------------------------- 1 | /* Verifies that mapping over the stack segment is disallowed. */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | int handle; 13 | uintptr_t handle_page = ROUND_DOWN ((uintptr_t) &handle, 4096); 14 | 15 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 16 | CHECK (mmap (handle, (void *) handle_page) == MAP_FAILED, 17 | "try to mmap over stack segment"); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-over-stk.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-over-stk) begin 7 | (mmap-over-stk) open "sample.txt" 8 | (mmap-over-stk) try to mmap over stack segment 9 | (mmap-over-stk) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-overlap.c: -------------------------------------------------------------------------------- 1 | /* Verifies that overlapping memory mappings are disallowed. */ 2 | 3 | #include 4 | #include "tests/vm/sample.inc" 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | char *start = (char *) 0x10000000; 12 | int fd[2]; 13 | 14 | CHECK ((fd[0] = open ("zeros")) > 1, "open \"zeros\" once"); 15 | CHECK (mmap (fd[0], start) != MAP_FAILED, "mmap \"zeros\""); 16 | CHECK ((fd[1] = open ("zeros")) > 1 && fd[0] != fd[1], 17 | "open \"zeros\" again"); 18 | CHECK (mmap (fd[1], start + 4096) == MAP_FAILED, 19 | "try to mmap \"zeros\" again"); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-overlap.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-overlap) begin 7 | (mmap-overlap) open "zeros" once 8 | (mmap-overlap) mmap "zeros" 9 | (mmap-overlap) open "zeros" again 10 | (mmap-overlap) try to mmap "zeros" again 11 | (mmap-overlap) end 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-read.c: -------------------------------------------------------------------------------- 1 | /* Uses a memory mapping to read a file. */ 2 | 3 | #include 4 | #include 5 | #include "tests/vm/sample.inc" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | void 10 | test_main (void) 11 | { 12 | char *actual = (char *) 0x10000000; 13 | int handle; 14 | mapid_t map; 15 | size_t i; 16 | 17 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 18 | CHECK ((map = mmap (handle, actual)) != MAP_FAILED, "mmap \"sample.txt\""); 19 | 20 | /* Check that data is correct. */ 21 | if (memcmp (actual, sample, strlen (sample))) 22 | fail ("read of mmap'd file reported bad data"); 23 | 24 | /* Verify that data is followed by zeros. */ 25 | for (i = strlen (sample); i < 4096; i++) 26 | if (actual[i] != 0) 27 | fail ("byte %zu of mmap'd region has value %02hhx (should be 0)", 28 | i, actual[i]); 29 | 30 | munmap (map); 31 | close (handle); 32 | } 33 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-read.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-read) begin 7 | (mmap-read) open "sample.txt" 8 | (mmap-read) mmap "sample.txt" 9 | (mmap-read) end 10 | EOF 11 | pass; 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-remove.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-remove) begin 7 | (mmap-remove) open "sample.txt" 8 | (mmap-remove) mmap "sample.txt" 9 | (mmap-remove) remove "sample.txt" 10 | (mmap-remove) try to open "sample.txt" 11 | (mmap-remove) create "another" 12 | (mmap-remove) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-twice.c: -------------------------------------------------------------------------------- 1 | /* Maps the same file into memory twice and verifies that the 2 | same data is readable in both. */ 3 | 4 | #include 5 | #include 6 | #include "tests/vm/sample.inc" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | char *actual[2] = {(char *) 0x10000000, (char *) 0x20000000}; 14 | size_t i; 15 | int handle[2]; 16 | 17 | for (i = 0; i < 2; i++) 18 | { 19 | CHECK ((handle[i] = open ("sample.txt")) > 1, 20 | "open \"sample.txt\" #%zu", i); 21 | CHECK (mmap (handle[i], actual[i]) != MAP_FAILED, 22 | "mmap \"sample.txt\" #%zu at %p", i, (void *) actual[i]); 23 | } 24 | 25 | for (i = 0; i < 2; i++) 26 | CHECK (!memcmp (actual[i], sample, strlen (sample)), 27 | "compare mmap'd file %zu against data", i); 28 | } 29 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-twice.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-twice) begin 7 | (mmap-twice) open "sample.txt" #0 8 | (mmap-twice) mmap "sample.txt" #0 at 0x10000000 9 | (mmap-twice) open "sample.txt" #1 10 | (mmap-twice) mmap "sample.txt" #1 at 0x20000000 11 | (mmap-twice) compare mmap'd file 0 against data 12 | (mmap-twice) compare mmap'd file 1 against data 13 | (mmap-twice) end 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-unmap.c: -------------------------------------------------------------------------------- 1 | /* Maps and unmaps a file and verifies that the mapped region is 2 | inaccessible afterward. */ 3 | 4 | #include 5 | #include "tests/vm/sample.inc" 6 | #include "tests/lib.h" 7 | #include "tests/main.h" 8 | 9 | #define ACTUAL ((void *) 0x10000000) 10 | 11 | void 12 | test_main (void) 13 | { 14 | int handle; 15 | mapid_t map; 16 | 17 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 18 | CHECK ((map = mmap (handle, ACTUAL)) != MAP_FAILED, "mmap \"sample.txt\""); 19 | 20 | munmap (map); 21 | 22 | fail ("unmapped memory is readable (%d)", *(int *) ACTUAL); 23 | } 24 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-unmap.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::vm::process_death; 6 | 7 | check_process_death ('mmap-unmap'); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-write.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (mmap-write) begin 7 | (mmap-write) create "sample.txt" 8 | (mmap-write) open "sample.txt" 9 | (mmap-write) mmap "sample.txt" 10 | (mmap-write) compare read data against written data 11 | (mmap-write) end 12 | EOF 13 | pass; 14 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-zero.c: -------------------------------------------------------------------------------- 1 | /* Tries to map a zero-length file, which may or may not work but 2 | should not terminate the process or crash. 3 | Then dereferences the address that we tried to map, 4 | and the process must be terminated with -1 exit code. */ 5 | 6 | #include 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | char *data = (char *) 0x7f000000; 14 | int handle; 15 | 16 | CHECK (create ("empty", 0), "create empty file \"empty\""); 17 | CHECK ((handle = open ("empty")) > 1, "open \"empty\""); 18 | 19 | /* Calling mmap() might succeed or fail. We don't care. */ 20 | msg ("mmap \"empty\""); 21 | mmap (handle, data); 22 | 23 | /* Regardless of whether the call worked, *data should cause 24 | the process to be terminated. */ 25 | fail ("unmapped memory is readable (%d)", *data); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/mmap-zero.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (mmap-zero) begin 7 | (mmap-zero) create empty file "empty" 8 | (mmap-zero) open "empty" 9 | (mmap-zero) mmap "empty" 10 | mmap-zero: exit(-1) 11 | EOF 12 | pass; 13 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-linear.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (page-linear) begin 7 | (page-linear) initialize 8 | (page-linear) read pass 9 | (page-linear) read/modify/write pass one 10 | (page-linear) read/modify/write pass two 11 | (page-linear) read pass 12 | (page-linear) end 13 | EOF 14 | pass; 15 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-mm.c: -------------------------------------------------------------------------------- 1 | #include "tests/main.h" 2 | #include "tests/vm/parallel-merge.h" 3 | 4 | void 5 | test_main (void) 6 | { 7 | parallel_merge ("child-qsort-mm", 80); 8 | } 9 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-mm.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (page-merge-mm) begin 7 | (page-merge-mm) init 8 | (page-merge-mm) sort chunk 0 9 | (page-merge-mm) sort chunk 1 10 | (page-merge-mm) sort chunk 2 11 | (page-merge-mm) sort chunk 3 12 | (page-merge-mm) sort chunk 4 13 | (page-merge-mm) sort chunk 5 14 | (page-merge-mm) sort chunk 6 15 | (page-merge-mm) sort chunk 7 16 | (page-merge-mm) wait for child 0 17 | (page-merge-mm) wait for child 1 18 | (page-merge-mm) wait for child 2 19 | (page-merge-mm) wait for child 3 20 | (page-merge-mm) wait for child 4 21 | (page-merge-mm) wait for child 5 22 | (page-merge-mm) wait for child 6 23 | (page-merge-mm) wait for child 7 24 | (page-merge-mm) merge 25 | (page-merge-mm) verify 26 | (page-merge-mm) success, buf_idx=1,048,576 27 | (page-merge-mm) end 28 | EOF 29 | pass; 30 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-par.c: -------------------------------------------------------------------------------- 1 | #include "tests/main.h" 2 | #include "tests/vm/parallel-merge.h" 3 | 4 | void 5 | test_main (void) 6 | { 7 | parallel_merge ("child-sort", 123); 8 | } 9 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-par.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (page-merge-par) begin 7 | (page-merge-par) init 8 | (page-merge-par) sort chunk 0 9 | (page-merge-par) sort chunk 1 10 | (page-merge-par) sort chunk 2 11 | (page-merge-par) sort chunk 3 12 | (page-merge-par) sort chunk 4 13 | (page-merge-par) sort chunk 5 14 | (page-merge-par) sort chunk 6 15 | (page-merge-par) sort chunk 7 16 | (page-merge-par) wait for child 0 17 | (page-merge-par) wait for child 1 18 | (page-merge-par) wait for child 2 19 | (page-merge-par) wait for child 3 20 | (page-merge-par) wait for child 4 21 | (page-merge-par) wait for child 5 22 | (page-merge-par) wait for child 6 23 | (page-merge-par) wait for child 7 24 | (page-merge-par) merge 25 | (page-merge-par) verify 26 | (page-merge-par) success, buf_idx=1,048,576 27 | (page-merge-par) end 28 | EOF 29 | pass; 30 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-seq.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (page-merge-seq) begin 7 | (page-merge-seq) init 8 | (page-merge-seq) sort chunk 0 9 | (page-merge-seq) sort chunk 1 10 | (page-merge-seq) sort chunk 2 11 | (page-merge-seq) sort chunk 3 12 | (page-merge-seq) sort chunk 4 13 | (page-merge-seq) sort chunk 5 14 | (page-merge-seq) sort chunk 6 15 | (page-merge-seq) sort chunk 7 16 | (page-merge-seq) sort chunk 8 17 | (page-merge-seq) sort chunk 9 18 | (page-merge-seq) sort chunk 10 19 | (page-merge-seq) sort chunk 11 20 | (page-merge-seq) sort chunk 12 21 | (page-merge-seq) sort chunk 13 22 | (page-merge-seq) sort chunk 14 23 | (page-merge-seq) sort chunk 15 24 | (page-merge-seq) merge 25 | (page-merge-seq) verify 26 | (page-merge-seq) success, buf_idx=1,032,192 27 | (page-merge-seq) end 28 | EOF 29 | pass; 30 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-stk.c: -------------------------------------------------------------------------------- 1 | #include "tests/main.h" 2 | #include "tests/vm/parallel-merge.h" 3 | 4 | void 5 | test_main (void) 6 | { 7 | parallel_merge ("child-qsort", 72); 8 | } 9 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-merge-stk.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (page-merge-stk) begin 7 | (page-merge-stk) init 8 | (page-merge-stk) sort chunk 0 9 | (page-merge-stk) sort chunk 1 10 | (page-merge-stk) sort chunk 2 11 | (page-merge-stk) sort chunk 3 12 | (page-merge-stk) sort chunk 4 13 | (page-merge-stk) sort chunk 5 14 | (page-merge-stk) sort chunk 6 15 | (page-merge-stk) sort chunk 7 16 | (page-merge-stk) wait for child 0 17 | (page-merge-stk) wait for child 1 18 | (page-merge-stk) wait for child 2 19 | (page-merge-stk) wait for child 3 20 | (page-merge-stk) wait for child 4 21 | (page-merge-stk) wait for child 5 22 | (page-merge-stk) wait for child 6 23 | (page-merge-stk) wait for child 7 24 | (page-merge-stk) merge 25 | (page-merge-stk) verify 26 | (page-merge-stk) success, buf_idx=1,048,576 27 | (page-merge-stk) end 28 | EOF 29 | pass; 30 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-parallel.c: -------------------------------------------------------------------------------- 1 | /* Runs 4 child-linear processes at once. */ 2 | 3 | #include 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | #define CHILD_CNT 4 8 | 9 | void 10 | test_main (void) 11 | { 12 | pid_t children[CHILD_CNT]; 13 | int i; 14 | 15 | for (i = 0; i < CHILD_CNT; i++) 16 | CHECK ((children[i] = exec ("child-linear")) != -1, 17 | "exec \"child-linear\""); 18 | 19 | for (i = 0; i < CHILD_CNT; i++) 20 | CHECK (wait (children[i]) == 0x42, "wait for child %d", i); 21 | } 22 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-parallel.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (page-parallel) begin 7 | (page-parallel) exec "child-linear" 8 | (page-parallel) exec "child-linear" 9 | (page-parallel) exec "child-linear" 10 | (page-parallel) exec "child-linear" 11 | (page-parallel) wait for child 0 12 | (page-parallel) wait for child 1 13 | (page-parallel) wait for child 2 14 | (page-parallel) wait for child 3 15 | (page-parallel) end 16 | EOF 17 | pass; 18 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/page-shuffle.c: -------------------------------------------------------------------------------- 1 | /* Shuffles a 128 kB data buffer 10 times, printing the checksum 2 | after each time. */ 3 | 4 | #include 5 | #include "tests/arc4.h" 6 | #include "tests/cksum.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | #define SIZE (128 * 1024) 11 | 12 | static char buf[SIZE]; 13 | 14 | void 15 | test_main (void) 16 | { 17 | size_t i; 18 | 19 | /* Initialize. */ 20 | for (i = 0; i < sizeof buf; i++) 21 | buf[i] = i * 257; 22 | msg ("init: cksum=%lu", cksum (buf, sizeof buf)); 23 | 24 | /* Shuffle repeatedly. */ 25 | for (i = 0; i < 10; i++) 26 | { 27 | shuffle (buf, sizeof buf, 1); 28 | msg ("shuffle %zu: cksum=%lu", i, cksum (buf, sizeof buf)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/parallel-merge.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_VM_PARALLEL_MERGE 2 | #define TESTS_VM_PARALLEL_MERGE 1 3 | 4 | void parallel_merge (const char *child_name, int exit_status); 5 | 6 | #endif /* tests/vm/parallel-merge.h */ 7 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/process_death.pm: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | 6 | sub check_process_death { 7 | my ($proc_name) = @_; 8 | our ($test); 9 | my (@output) = read_text_file ("$test.output"); 10 | 11 | common_checks ("run", @output); 12 | @output = get_core_output ("run", @output); 13 | fail "First line of output is not `($proc_name) begin' message.\n" 14 | if $output[0] ne "($proc_name) begin"; 15 | fail "Output missing '$proc_name: exit(-1)' message.\n" 16 | if !grep ("$proc_name: exit(-1)" eq $_, @output); 17 | fail "Output contains '($proc_name) end' message.\n" 18 | if grep (/\($proc_name\) end/, @output); 19 | pass; 20 | } 21 | 22 | 1; 23 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-bad-addr.c: -------------------------------------------------------------------------------- 1 | /* Accesses a bad address. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | fail ("bad addr read as %d", *(int *) 0x04000000); 11 | } 12 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-bad-addr.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::vm::process_death; 6 | 7 | check_process_death ('pt-bad-addr'); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-bad-read.c: -------------------------------------------------------------------------------- 1 | /* Reads from a file into a bad address. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/lib.h" 6 | #include "tests/main.h" 7 | 8 | void 9 | test_main (void) 10 | { 11 | int handle; 12 | 13 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 14 | read (handle, (char *) &handle - 4096, 1); 15 | fail ("survived reading data into bad address"); 16 | } 17 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-bad-read.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (pt-bad-read) begin 7 | (pt-bad-read) open "sample.txt" 8 | pt-bad-read: exit(-1) 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-big-stk-obj.c: -------------------------------------------------------------------------------- 1 | /* Allocates and writes to a 64 kB object on the stack. 2 | This must succeed. */ 3 | 4 | #include 5 | #include "tests/arc4.h" 6 | #include "tests/cksum.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | char stk_obj[65536]; 14 | struct arc4 arc4; 15 | 16 | arc4_init (&arc4, "foobar", 6); 17 | memset (stk_obj, 0, sizeof stk_obj); 18 | arc4_crypt (&arc4, stk_obj, sizeof stk_obj); 19 | msg ("cksum: %lu", cksum (stk_obj, sizeof stk_obj)); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-big-stk-obj.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (pt-big-stk-obj) begin 7 | (pt-big-stk-obj) cksum: 3256410166 8 | (pt-big-stk-obj) end 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-bad.c: -------------------------------------------------------------------------------- 1 | /* Read from an address 4,096 bytes below the stack pointer. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include 5 | #include "tests/arc4.h" 6 | #include "tests/cksum.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | asm volatile ("movl -4096(%esp), %eax"); 14 | } 15 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-bad.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_USER_FAULTS => 1, [<<'EOF']); 6 | (pt-grow-bad) begin 7 | pt-grow-bad: exit(-1) 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-pusha.c: -------------------------------------------------------------------------------- 1 | /* Expand the stack by 32 bytes all at once using the PUSHA 2 | instruction. 3 | This must succeed. */ 4 | 5 | #include 6 | #include "tests/arc4.h" 7 | #include "tests/cksum.h" 8 | #include "tests/lib.h" 9 | #include "tests/main.h" 10 | 11 | void 12 | test_main (void) 13 | { 14 | asm volatile 15 | ("movl %%esp, %%eax;" /* Save a copy of the stack pointer. */ 16 | "andl $0xfffff000, %%esp;" /* Move stack pointer to bottom of page. */ 17 | "pushal;" /* Push 32 bytes on stack at once. */ 18 | "movl %%eax, %%esp" /* Restore copied stack pointer. */ 19 | : : : "eax"); /* Tell GCC we destroyed eax. */ 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-pusha.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (pt-grow-pusha) begin 7 | (pt-grow-pusha) end 8 | EOF 9 | pass; 10 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-stack.c: -------------------------------------------------------------------------------- 1 | /* Demonstrate that the stack can grow. 2 | This must succeed. */ 3 | 4 | #include 5 | #include "tests/arc4.h" 6 | #include "tests/cksum.h" 7 | #include "tests/lib.h" 8 | #include "tests/main.h" 9 | 10 | void 11 | test_main (void) 12 | { 13 | char stack_obj[4096]; 14 | struct arc4 arc4; 15 | 16 | arc4_init (&arc4, "foobar", 6); 17 | memset (stack_obj, 0, sizeof stack_obj); 18 | arc4_crypt (&arc4, stack_obj, sizeof stack_obj); 19 | msg ("cksum: %lu", cksum (stack_obj, sizeof stack_obj)); 20 | } 21 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-stack.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (pt-grow-stack) begin 7 | (pt-grow-stack) cksum: 3424492700 8 | (pt-grow-stack) end 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-grow-stk-sc.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']); 6 | (pt-grow-stk-sc) begin 7 | (pt-grow-stk-sc) create "sample.txt" 8 | (pt-grow-stk-sc) open "sample.txt" 9 | (pt-grow-stk-sc) write "sample.txt" 10 | (pt-grow-stk-sc) 2nd open "sample.txt" 11 | (pt-grow-stk-sc) read "sample.txt" 12 | (pt-grow-stk-sc) compare written data against read data 13 | (pt-grow-stk-sc) end 14 | EOF 15 | pass; 16 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-write-code-2.c: -------------------------------------------------------------------------------- 1 | /* Try to write to the code segment using a system call. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | int handle; 11 | 12 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); 13 | read (handle, (void *) test_main, 1); 14 | fail ("survived reading data into code segment"); 15 | } 16 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-write-code.c: -------------------------------------------------------------------------------- 1 | /* Try to write to the code segment. 2 | The process must be terminated with -1 exit code. */ 3 | 4 | #include "tests/lib.h" 5 | #include "tests/main.h" 6 | 7 | void 8 | test_main (void) 9 | { 10 | *(int *) test_main = 0; 11 | fail ("writing the code segment succeeded"); 12 | } 13 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-write-code.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | use tests::vm::process_death; 6 | 7 | check_process_death ('pt-write-code'); 8 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/pt-write-code2.ck: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | use strict; 3 | use warnings; 4 | use tests::tests; 5 | check_expected ([<<'EOF']); 6 | (pt-write-code2) begin 7 | (pt-write-code2) open "sample.txt" 8 | pt-write-code2: exit(-1) 9 | EOF 10 | pass; 11 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/qsort.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTS_VM_QSORT_H 2 | #define TESTS_VM_QSORT_H 1 3 | 4 | #include 5 | 6 | void qsort_bytes (unsigned char *buf, size_t size); 7 | 8 | #endif /* tests/vm/qsort.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/tests/vm/sample.txt: -------------------------------------------------------------------------------- 1 | === ALL USERS PLEASE NOTE ======================== 2 | 3 | CAR and CDR now return extra values. 4 | 5 | The function CAR now returns two values. Since it has to go to the 6 | trouble to figure out if the object is carcdr-able anyway, we figured 7 | you might as well get both halves at once. For example, the following 8 | code shows how to destructure a cons (SOME-CONS) into its two slots 9 | (THE-CAR and THE-CDR): 10 | 11 | (MULTIPLE-VALUE-BIND (THE-CAR THE-CDR) (CAR SOME-CONS) ...) 12 | 13 | For symmetry with CAR, CDR returns a second value which is the CAR of 14 | the object. In a related change, the functions MAKE-ARRAY and CONS 15 | have been fixed so they don't allocate any storage except on the 16 | stack. This should hopefully help people who don't like using the 17 | garbage collector because it cold boots the machine so often. 18 | -------------------------------------------------------------------------------- /pintos/src/threads/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | bochsrc.txt 3 | bochsout.txt 4 | -------------------------------------------------------------------------------- /pintos/src/threads/Make.vars: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | kernel.bin: DEFINES = 4 | KERNEL_SUBDIRS = threads devices lib lib/kernel $(TEST_SUBDIRS) 5 | TEST_SUBDIRS = tests/threads 6 | GRADING_FILE = $(SRCDIR)/tests/threads/Grading 7 | SIMULATOR = --bochs 8 | -------------------------------------------------------------------------------- /pintos/src/threads/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.kernel 2 | -------------------------------------------------------------------------------- /pintos/src/threads/flags.h: -------------------------------------------------------------------------------- 1 | #ifndef THREADS_FLAGS_H 2 | #define THREADS_FLAGS_H 3 | 4 | /* EFLAGS Register. */ 5 | #define FLAG_MBS 0x00000002 /* Must be set. */ 6 | #define FLAG_IF 0x00000200 /* Interrupt Flag. */ 7 | 8 | #endif /* threads/flags.h */ 9 | -------------------------------------------------------------------------------- /pintos/src/threads/init.h: -------------------------------------------------------------------------------- 1 | #ifndef THREADS_INIT_H 2 | #define THREADS_INIT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* Page directory with kernel mappings only. */ 10 | extern uint32_t *init_page_dir; 11 | 12 | #endif /* threads/init.h */ 13 | -------------------------------------------------------------------------------- /pintos/src/threads/intr-stubs.h: -------------------------------------------------------------------------------- 1 | #ifndef THREADS_INTR_STUBS_H 2 | #define THREADS_INTR_STUBS_H 3 | 4 | /* Interrupt stubs. 5 | 6 | These are little snippets of code in intr-stubs.S, one for 7 | each of the 256 possible x86 interrupts. Each one does a 8 | little bit of stack manipulation, then jumps to intr_entry(). 9 | See intr-stubs.S for more information. 10 | 11 | This array points to each of the interrupt stub entry points 12 | so that intr_init() can easily find them. */ 13 | typedef void intr_stub_func (void); 14 | extern intr_stub_func *intr_stubs[256]; 15 | 16 | /* Interrupt return path. */ 17 | void intr_exit (void); 18 | 19 | #endif /* threads/intr-stubs.h */ 20 | -------------------------------------------------------------------------------- /pintos/src/threads/kernel.lds.S: -------------------------------------------------------------------------------- 1 | #include "threads/loader.h" 2 | 3 | OUTPUT_FORMAT("elf32-i386") 4 | OUTPUT_ARCH("i386") 5 | ENTRY(start) /* Kernel starts at "start" symbol. */ 6 | SECTIONS 7 | { 8 | /* Specify the kernel base address. */ 9 | _start = LOADER_PHYS_BASE + LOADER_KERN_BASE; 10 | 11 | /* Make room for the ELF headers. */ 12 | . = _start + SIZEOF_HEADERS; 13 | 14 | /* Kernel starts with code, followed by read-only data and writable data. */ 15 | .text : { *(.start) *(.text) } = 0x90 16 | .rodata : { *(.rodata) *(.rodata.*) 17 | . = ALIGN(0x1000); 18 | _end_kernel_text = .; } 19 | .data : { *(.data) 20 | _signature = .; LONG(0xaa55aa55) } 21 | 22 | /* BSS (zero-initialized data) is after everything else. */ 23 | _start_bss = .; 24 | .bss : { *(.bss) } 25 | _end_bss = .; 26 | 27 | _end = .; 28 | 29 | ASSERT (_end - _start <= 512K, "Kernel image is too big.") 30 | } 31 | -------------------------------------------------------------------------------- /pintos/src/threads/malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef THREADS_MALLOC_H 2 | #define THREADS_MALLOC_H 3 | 4 | #include 5 | #include 6 | 7 | void malloc_init (void); 8 | void *malloc (size_t) __attribute__ ((malloc)); 9 | void *calloc (size_t, size_t) __attribute__ ((malloc)); 10 | void *realloc (void *, size_t); 11 | void free (void *); 12 | 13 | #endif /* threads/malloc.h */ 14 | -------------------------------------------------------------------------------- /pintos/src/threads/palloc.h: -------------------------------------------------------------------------------- 1 | #ifndef THREADS_PALLOC_H 2 | #define THREADS_PALLOC_H 3 | 4 | #include 5 | 6 | /* How to allocate pages. */ 7 | enum palloc_flags 8 | { 9 | PAL_ASSERT = 001, /* Panic on failure. */ 10 | PAL_ZERO = 002, /* Zero page contents. */ 11 | PAL_USER = 004 /* User page. */ 12 | }; 13 | 14 | void palloc_init (size_t user_page_limit); 15 | void *palloc_get_page (enum palloc_flags); 16 | void *palloc_get_multiple (enum palloc_flags, size_t page_cnt); 17 | void palloc_free_page (void *); 18 | void palloc_free_multiple (void *, size_t page_cnt); 19 | 20 | #endif /* threads/palloc.h */ 21 | -------------------------------------------------------------------------------- /pintos/src/userprog/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | bochsrc.txt 3 | bochsout.txt 4 | -------------------------------------------------------------------------------- /pintos/src/userprog/Make.vars: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | kernel.bin: DEFINES = -DUSERPROG -DFILESYS 4 | KERNEL_SUBDIRS = threads devices lib lib/kernel userprog filesys 5 | TEST_SUBDIRS = tests/userprog tests/userprog/no-vm tests/filesys/base 6 | GRADING_FILE = $(SRCDIR)/tests/userprog/Grading 7 | SIMULATOR = --qemu 8 | -------------------------------------------------------------------------------- /pintos/src/userprog/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.kernel 2 | -------------------------------------------------------------------------------- /pintos/src/userprog/exception.h: -------------------------------------------------------------------------------- 1 | #ifndef USERPROG_EXCEPTION_H 2 | #define USERPROG_EXCEPTION_H 3 | 4 | /* Page fault error code bits that describe the cause of the exception. */ 5 | #define PF_P 0x1 /* 0: not-present page. 1: access rights violation. */ 6 | #define PF_W 0x2 /* 0: read, 1: write. */ 7 | #define PF_U 0x4 /* 0: kernel, 1: user process. */ 8 | 9 | void exception_init (void); 10 | void exception_print_stats (void); 11 | 12 | #endif /* userprog/exception.h */ 13 | -------------------------------------------------------------------------------- /pintos/src/userprog/gdt.h: -------------------------------------------------------------------------------- 1 | #ifndef USERPROG_GDT_H 2 | #define USERPROG_GDT_H 3 | 4 | #include "threads/loader.h" 5 | 6 | /* Segment selectors. 7 | More selectors are defined by the loader in loader.h. */ 8 | #define SEL_UCSEG 0x1B /* User code selector. */ 9 | #define SEL_UDSEG 0x23 /* User data selector. */ 10 | #define SEL_TSS 0x28 /* Task-state segment. */ 11 | #define SEL_CNT 6 /* Number of segments. */ 12 | 13 | void gdt_init (void); 14 | 15 | #endif /* userprog/gdt.h */ 16 | -------------------------------------------------------------------------------- /pintos/src/userprog/pagedir.h: -------------------------------------------------------------------------------- 1 | #ifndef USERPROG_PAGEDIR_H 2 | #define USERPROG_PAGEDIR_H 3 | 4 | #include 5 | #include 6 | 7 | uint32_t *pagedir_create (void); 8 | void pagedir_destroy (uint32_t *pd); 9 | bool pagedir_set_page (uint32_t *pd, void *upage, void *kpage, bool rw); 10 | void *pagedir_get_page (uint32_t *pd, const void *upage); 11 | void pagedir_clear_page (uint32_t *pd, void *upage); 12 | bool pagedir_is_dirty (uint32_t *pd, const void *upage); 13 | void pagedir_set_dirty (uint32_t *pd, const void *upage, bool dirty); 14 | bool pagedir_is_accessed (uint32_t *pd, const void *upage); 15 | void pagedir_set_accessed (uint32_t *pd, const void *upage, bool accessed); 16 | void pagedir_activate (uint32_t *pd); 17 | 18 | #endif /* userprog/pagedir.h */ 19 | -------------------------------------------------------------------------------- /pintos/src/userprog/process.h: -------------------------------------------------------------------------------- 1 | #ifndef USERPROG_PROCESS_H 2 | #define USERPROG_PROCESS_H 3 | 4 | #include "threads/thread.h" 5 | 6 | tid_t process_execute (const char *file_name); 7 | int process_wait (tid_t); 8 | void process_exit (void); 9 | void process_activate (void); 10 | 11 | #endif /* userprog/process.h */ 12 | -------------------------------------------------------------------------------- /pintos/src/userprog/tss.h: -------------------------------------------------------------------------------- 1 | #ifndef USERPROG_TSS_H 2 | #define USERPROG_TSS_H 3 | 4 | #include 5 | 6 | struct tss; 7 | void tss_init (void); 8 | struct tss *tss_get (void); 9 | void tss_update (void); 10 | 11 | #endif /* userprog/tss.h */ 12 | -------------------------------------------------------------------------------- /pintos/src/utils/.gitignore: -------------------------------------------------------------------------------- 1 | setitimer-helper 2 | squish-pty 3 | squish-unix 4 | -------------------------------------------------------------------------------- /pintos/src/utils/Makefile: -------------------------------------------------------------------------------- 1 | all: setitimer-helper squish-pty squish-unix 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -W 5 | LOADLIBES = -lm 6 | setitimer-helper: setitimer-helper.o 7 | squish-pty: squish-pty.o 8 | squish-unix: squish-unix.o 9 | 10 | clean: 11 | rm -f *.o setitimer-helper squish-pty squish-unix 12 | -------------------------------------------------------------------------------- /pintos/src/utils/pintos-gdb: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Path to GDB macros file. Customize for your site. 4 | GDBMACROS=/home/vagrant/.bin/gdb-macros 5 | 6 | # Choose correct GDB. 7 | if command -v i386-elf-gdb >/dev/null 2>&1; then 8 | GDB=i386-elf-gdb 9 | else 10 | GDB=cgdb 11 | fi 12 | 13 | # Run GDB. 14 | if test -f "$GDBMACROS"; then 15 | exec $GDB -x "$GDBMACROS" "$@" 16 | else 17 | echo "*** $GDBMACROS does not exist ***" 18 | echo "*** Pintos GDB macros will not be available ***" 19 | exec $GDB "$@" 20 | fi 21 | -------------------------------------------------------------------------------- /pintos/src/vm/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | bochsrc.txt 3 | bochsout.txt 4 | -------------------------------------------------------------------------------- /pintos/src/vm/Make.vars: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | kernel.bin: DEFINES = -DUSERPROG -DFILESYS -DVM 4 | KERNEL_SUBDIRS = threads devices lib lib/kernel userprog filesys vm 5 | TEST_SUBDIRS = tests/userprog tests/vm tests/filesys/base 6 | GRADING_FILE = $(SRCDIR)/tests/vm/Grading 7 | SIMULATOR = --qemu 8 | -------------------------------------------------------------------------------- /pintos/src/vm/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.kernel 2 | -------------------------------------------------------------------------------- /pintos/utils/run.sh: -------------------------------------------------------------------------------- 1 | PROGRAMS="bubsort \ 2 | cat \ 3 | cmp \ 4 | cp \ 5 | echo \ 6 | hex-dump \ 7 | insult \ 8 | ls \ 9 | mkdir \ 10 | pwd \ 11 | rm \ 12 | shell" 13 | EXAMPLES="../../examples" 14 | CMDLINE="pintos --filesys-size=100" 15 | CMDLINE_END="-f -q run 'shell'" 16 | 17 | for PROGRAM in $PROGRAMS; do 18 | CMDLINE+=" -p $EXAMPLES/$PROGRAM -a $PROGRAM" 19 | done 20 | CMDLINE+=" -- $CMDLINE_END" 21 | echo $CMDLINE 22 | eval $CMDLINE 23 | --------------------------------------------------------------------------------