-Ben,
-
-it seems the priority donation tests are somewhat incomplete and allow
-incorrect implementations to pass with a perfect score.
-
-We are seeing the following wrong implementations pass all tests:
-
-- Implementations that assume locks are released in the opposite order
-in which they're acquired. The students implement this by
-popping/pushing on the donation list.
-
-- Implementations that assume that the priority of a thread waiting on
-a semaphore or condition variable cannot change between when the
-thread was blocked and when it is unblocked. The students implement
-this by doing an insert into an ordered list on block, rather than
-picking the maximum thread on unblock.
-
-Neither of these two cases is detected; do you currently check for
-these mistakes manually?
-
-I wrote a test that checks for the first case; it is here:
-http://people.cs.vt.edu/~gback/pintos/priority-donate-multiple-2.patch
-
-[...]
-
-I also wrote a test case for the second scenario:
-http://people.cs.vt.edu/~gback/pintos/priority-donate-sema.c
-http://people.cs.vt.edu/~gback/pintos/priority-donate-sema.ck
-
-I put the other tests up here:
-http://people.cs.vt.edu/~gback/pintos/priority-donate-multiple2.c
-http://people.cs.vt.edu/~gback/pintos/priority-donate-multiple2.ck
-
-From: "Godmar Back" <godmar@gmail.com>
-Subject: multiple threads waking up at same clock tick
-To: "Ben Pfaff" <blp@cs.stanford.edu>
-Date: Wed, 1 Mar 2006 08:14:47 -0500
-
-Greg Benson points out another potential TODO item for P1.
-
-----
-One thing I recall:
-
-The alarm tests do not test to see if multiple threads are woken up if
-their timers have expired. That is, students can write a solution
-that just wakes up the first thread on the sleep queue rather than
-check for additional threads. Of course, the next thread will be
-woken up on the next tick. Also, this might be hard to test.
-
----
-Way to test this: (from Godmar Back)
-
-Thread A with high priority spins until 'ticks' changes, then calls to
-timer_sleep(X), Thread B with lower priority is then resumed, calls
-set_priority to make its priority equal to that of thread A, then
-calls timer_sleep(X), all of that before the next clock interrupt
-arrives.
-
-On wakeup, each thread records wake-up time and calls yield
-immediately, forcing the scheduler to switch to the other
-equal-priority thread. Both wake-up times must be the same (and match
-the planned wake-up time.)
-
-From: "Waqar Mohsin" <wmohsin@gmail.com>
-Subject: 3 questions about switch_threads() in switch.S
-To: blp@cs.stanford.edu, joshwise@stanford.edu
-Date: Fri, 3 Mar 2006 17:09:21 -0800
-
-QUESTION 1
-
-In the section
-
- # Save current stack pointer to old thread's stack, if any.
- movl SWITCH_CUR(%esp), %eax
- test %eax, %eax
- jz 1f
- movl %esp, (%eax,%edx,1)
-1:
-
- # Restore stack pointer from new thread's stack.
- movl SWITCH_NEXT(%esp), %ecx
- movl (%ecx,%edx,1), %esp
-
-why are we saving the current stack pointer only if the "cur" thread pointer
-is non-NULL ? Isn't it gauranteed to be non-NULL because switch_threads() is
-only called form schedule(), where we have
-
- struct thread *cur = running_thread ();
-
-which should always be non-NULL (given the way kernel pool is laid out).
-
-QUESTION 2
-
- # This stack frame must match the one set up by thread_create().
- pushl %ebx
- pushl %ebp
- pushl %esi
- pushl %edi
-
-I find the comment confusing. thread_create() is a special case: the set of
-registers popped from switch_threads stack frame for a newly created thread
-are all zero, so their order shouldn't dictate the order above.
-
-I think all that matters is that the order of pops at the end of
-switch_threads() is the opposite of the pushes at the beginning (as shown
-above).
-
-QUESTION 3
-
-Is it true that struct switch_threads_frame does NOT strictly require
-
- struct thread *cur; /* 20: switch_threads()'s CUR argument. */
- struct thread *next; /* 24: switch_threads()'s NEXT argument. */
-at the end ?
-
-When a newly created thread's stack pointer is installed in switch_threads(),
-all we do is pop the saved registers and return to switch_entry() which pops
-off and discards the above two simulated (and not used) arguments to
-switch_threads().
-
-If we remove these two from struct switch_threads_frame and don't do a
-
- # Discard switch_threads() arguments.
- addl $8, %esp
-in switch_entry(), things should still work. Am I right ?
-
-Thanks
-Waqar
-
-From: "Godmar Back" <godmar@gmail.com>
-Subject: thread_yield in irq handler
-To: "Ben Pfaff" <blp@cs.stanford.edu>
-Date: Wed, 22 Feb 2006 22:18:50 -0500
-
-Ben,
-
-you write in your Tour of Pintos:
-
-"Second, an interrupt handler must not call any function that can
-sleep, which rules out thread_yield(), lock_acquire(), and many
-others. This is because external interrupts use space on the stack of
-the kernel thread that was running at the time the interrupt occurred.
-If the interrupt handler tried to sleep and that thread resumed, then
-the two uses of the single stack would interfere, which cannot be
-allowed."
-
-Is the last sentence really true?
-
-I thought the reason that you couldn't sleep is that you would put
-effectively a random thread/process to sleep, but I don't think it
-would cause problems with the kernel stack. After all, it doesn't
-cause this problem if you call thread_yield at the end of
-intr_handler(), so why would it cause this problem earlier.
-
-As for thread_yield(), my understanding is that the reason it's called
-at the end is to ensure it's done after the interrupt is acknowledged,
-which you can't do until the end because Pintos doesn't handle nested
-interrupts.
-
- - Godmar
-
-From: "Godmar Back" <godmar@gmail.com>
-
-For reasons I don't currently understand, some of our students seem
-hesitant to include each thread in a second "all-threads" list and are
-looking for ways to implement the advanced scheduler without one.