On Thu, 22 Feb 2001, Cy Chan wrote:
I guess my question was whether you considered the act
of taking the
quesiton out of the box as part of "answering the question". If you
release the lock before you call thread_yield, it seems like you're taking
the question out of the box, and then separately answering the question.
you get situations like:
teacher1 acquires the lock
teacher1 takes question1 out of the box and releases the lock
teacher2 acquires the lock
teacher2 takes question2 out of the box and releases the lock
student1 acquires the lock
student1 submits question3 and releases the lock
teacher3 acquires the lock
teacher3 takes question3 out of the box and releases the lock
teacher3 answers question3 (thread_yield)
teacher1 answers question1 (thread_yield)
teacher2 answers question2 (thread_yield)
so the order that we see messages saying that a teacher answered a
question has absolutely nothing to do with when it was taken out of the
box.
so what?
It seems like all the teachers could wait until the end of the
program before answering any of the questions.
not exactly. eventually your mailbox is going to fill, all the students
will be blocked waiting for space and then all the teachers will get to
run and 'answer' the questions.
in short: it shouldn't matter.
cy
On Thu, 22 Feb 2001, gwa wrote:
yes. i think you need to release the lock before
you call thread_yield...
why wouldn't you?
-gwa-
On Thu, 22 Feb 2001, Cy Chan wrote:
we're supposed to simulate tf's
answering questions with thread_yield.
but we can only allow one person to change the contents of the message box
at any given time. Should the tf who's answering a question release
control of the mailbox while she's answering the question?
this becomes a question of whether we want to be holding a lock while we
thread_yield. it doesn't make much sense to do so, because no one else
can do anything without the lock.
cy
_______________________________________________
cs161-list mailing list
cs161-list(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/cs161-list
_______________________________________________
cs161-list mailing list
cs161-list(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/cs161-list
_______________________________________________
cs161-list mailing list
cs161-list(a)fas.harvard.edu
http://www.fas.harvard.edu/mailman/listinfo/cs161-list