Commit graph

1259 commits

Author SHA1 Message Date
Robert Morris 328204d9cc not much 2019-07-20 18:51:31 -04:00
Robert Morris 06e49a58dc pi for pipe, rather than p, to avoid confusion with proc's p->lock 2019-07-20 17:07:20 -04:00
Robert Morris 3333665ab6 not much 2019-07-20 10:17:26 -04:00
Robert Morris 2418ac380c it's not clear that the release will always enable interrupts 2019-07-19 13:27:48 -04:00
Frans Kaashoek 06109901c9 x 2019-07-19 11:27:02 -04:00
Robert Morris dbd729b32d with per-proc locks, we don't need the intr_on() inside the loop. 2019-07-19 10:20:02 -04:00
Robert Morris 32168df609 no need to save/restore 14 2019-07-19 09:02:15 -04:00
Frans Kaashoek 9156632701 One way of supporting a guard page below kstack: allocate kstacks in
procinit() and map them high up (below TRAMPOLNE) with an empty
mapping below each stack.  Never free a kernel stack.

Another way would be to allocate and map them dynamically, but then we
need to reload page table when switching processes in scheduler()
and/or have a kernel pagetable per proc (if we want k->stack to be the
same virtual address in each process).

One gotcha: kernel addresses are not equal to physical addresses for
stack addresses.  A stack address must be translated if we need its
physical address (e.g., virtio passes a stack address to the disk).
2019-07-19 08:38:51 -04:00
Frans Kaashoek b924e44f06 Merge branch 'riscv' of g.csail.mit.edu:xv6-dev into riscv 2019-07-17 05:53:47 -04:00
Frans Kaashoek ce53416f49 Delete x86 comment 2019-07-17 05:53:34 -04:00
Robert Morris ebc3937209 conservatively call sfence.vma before every satp load. 2019-07-16 17:02:21 -04:00
Robert Morris 6bbc2b2245 cosmetic changes 2019-07-11 10:38:56 -04:00
Robert Morris 7797a38423 another test, to help with locking exercises 2019-07-11 05:41:59 -04:00
Robert Morris 4bc900e78b nits 2019-07-10 14:54:34 -04:00
Robert Morris e6addf25bb feeble attempt at build instructions 2019-07-10 10:30:33 -04:00
Robert Morris 061e3be6f8 more comment cleanup 2019-07-10 10:13:08 -04:00
Robert Morris c0266a877a document which proc fields are protected by p->lock 2019-07-10 09:28:00 -04:00
Robert Morris 5eb1685700 have kill() lock before looking at p->pid
document wait()'s use of np->parent w/o holding lock.
2019-07-10 09:24:50 -04:00
Robert Morris 9981bb2270 tweak some comments. 2019-07-10 08:57:51 -04:00
Frans Kaashoek 2f22a3ed6a Merge branch 'riscv-proc' into riscv 2019-07-08 15:50:06 -04:00
Robert Morris 60ed537427 Merge branch 'riscv-proc' of g.csail.mit.edu:xv6-dev into riscv-proc 2019-07-08 11:11:29 -04:00
Robert Morris 9d34838b4f holding p->lock all the way through state=RUNNABLE means we don't need EMBRYO 2019-07-08 11:11:00 -04:00
Frans Kaashoek adcc612901 Update runoff list for producing xv6.pdf 2019-07-08 08:50:55 -04:00
Robert Morris db72f3108f eliminate ptable. ptable.lock -> pid_lock. 2019-07-07 15:20:13 -04:00
Robert Morris 4ce3a5fa21 nits 2019-07-07 14:57:16 -04:00
Robert Morris c4f6a241cd avoid a double-lock of initproc->lock if child of init is reparenting 2019-07-07 07:03:28 -04:00
Robert Morris 7114bf43ed Merge branch 'riscv-proc' of g.csail.mit.edu:xv6-dev into riscv-proc 2019-07-07 06:39:58 -04:00
Robert Morris 62313be582 another fork test 2019-07-07 06:39:31 -04:00
Frans Kaashoek dabbc348bc Maybe fix two races identified by rtm (thx!):
- during exit(), hold p's parent lock and p's lock across all changes
to p and its parent (e.g., reparenting and wakeup1).  the lock
ordering between concurrent exits of children, parent, and great
parent might work out because processes form a tree.

- in wakeup1() test and set p->state atomically by asking caller to
have p locked.

a correctness proof would be desirable.
2019-07-06 16:38:41 -04:00
Robert Morris 75b0c6fc91 back-port fork/exit/exit tests to xv6-riscv 2019-07-05 12:33:26 -04:00
Robert Morris be88befed7 two exit/exit tests 2019-07-05 11:44:51 -04:00
Frans Kaashoek fab5e7c1de Make size in stat.h be a uint64
Supporting print long using %l (a bit of cheat)
Modify ls to print size using %l
We should probably update size in inode too.
2019-07-04 08:57:23 -04:00
Frans Kaashoek 6bfb078b14 x 2019-07-04 08:54:16 -04:00
Frans Kaashoek 47e69250d0 Simplify wakeup1 2019-07-03 15:38:30 -04:00
Frans Kaashoek cee830af24 Apply some corresponding bug fixes from wq branch here 2019-07-03 15:18:55 -04:00
Frans Kaashoek ccf299850b Remove some debugging code 2019-07-02 20:52:30 -04:00
Frans Kaashoek 26f306113a Fix a lost wakeup bug: the disk driver's wakeup() can run after the
reading process acquired p->lock and released virtio lock in sleep(),
but before the process had set p->status to SLEEPING, because the
wakeup tested p->status without holding p's lock.  Thus, wakeup can
complete without seeing any process SLEEPING and then p sets p->status
to SLEEPING.

Fix some other issues:

- Don't initialize proc lock in allocproc(), because freeproc() sets
np->state = UNUSED and allocproc() can choose np and calls initlock()
on the process's lock, releasing np's lock accidentally.  Move
initializing proc's lock to init.

- Protect nextpid using ptable.lock (and move into its own function)

Some clean up:
- Don't acquire p->lock when it p is used in a private way (e.g., exit()/grow()).
- Move find_runnable() back into scheduler().
2019-07-02 19:29:14 -04:00
Frans Kaashoek 1e4d7065d6 Merge branch 'riscv' into riscv-proc 2019-07-02 14:19:31 -04:00
Frans Kaashoek 84c759fc02 x 2019-07-02 14:09:38 -04:00
Frans Kaashoek 37ac6f8f4f Don't start processes at the end of the proc table 2019-07-02 13:55:52 -04:00
Frans Kaashoek da51735980 Avoid two cores selecting the same process to run 2019-07-02 13:40:33 -04:00
Robert Morris f59c1bf1d8 try to continue from walk() failing to allocate a page-table page 2019-07-02 11:45:06 -04:00
Robert Morris b27f275014 avoid allocproc() returning a struct proc with non-zero p->sz 2019-07-02 11:17:50 -04:00
Robert Morris 1540c8b15a COW tests 2019-07-02 11:04:35 -04:00
Frans Kaashoek 67702cf706 Checkpoint switching to per-process locks, in attempt clarify xv6's
locking plan, which is a difficult to understand because ptable lock
protects many invariants.  This implementation has a bug: once in a
while xv6 unlocks a proc lock that is locked by another core.
2019-07-02 09:14:47 -04:00
Robert Morris 40f1041a0a don't enable interrupts until done with sstatus, scause, &c 2019-07-02 05:20:11 -04:00
Robert Morris 535ac52efa oops, don't hold mycpu() result across intr_off() 2019-07-01 17:54:41 -04:00
Robert Morris abfe9999f4 have fork() fail, not panic, if not enough phys mem 2019-07-01 17:46:06 -04:00
Robert Morris 18e76a6c47 sbrk() returns a pointer, so it should be 64 bits 2019-07-01 17:01:50 -04:00
Robert Morris 9b99f00743 oops, don't hold mycpu() result across intr_off() 2019-07-01 14:15:18 -04:00