6.10 Exercises
-
1.
Comment out the calls to
acquire
andrelease
inkalloc
(kernel/kalloc.c:69). This seems like it should cause problems for kernel code that callskalloc
; what symptoms do you expect to see? When you run xv6, do you see these symptoms? How about when runningusertests
? If you don’t see a problem, why not? See if you can provoke a problem by inserting dummy loops into the critical section ofkalloc
. -
2.
Suppose that you instead commented out the locking in
kfree
(after restoring locking inkalloc
). What might now go wrong? Is lack of locks inkfree
less harmful than inkalloc
? -
3.
If two CPUs call
kalloc
at the same time, one will have to wait for the other, which is bad for performance. Modifykalloc.c
to have more parallelism, so that simultaneous calls tokalloc
from different CPUs can proceed without waiting for each other. -
4.
Write a parallel program using POSIX threads, which is supported on most operating systems. For example, implement a parallel hash table and measure if the number of puts/gets scales with increasing number of CPUs.
-
5.
Implement a subset of Pthreads in xv6. That is, implement a user-level thread library so that a user process can have more than 1 thread and arrange that these threads can run in parallel on different CPUs. Come up with a design that correctly handles a thread making a blocking system call and changing its shared address space.