summaryrefslogtreecommitdiffstats
path: root/proj1.txt
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-05-11 20:48:58 +0200
committermanuel <manuel@mausz.at>2012-05-11 20:48:58 +0200
commit9b19a84ed640cb15e6ca87ddc025c90d78a5fbdc (patch)
tree54345ae3ba366d1a4663e93b6b883e842f7a3918 /proj1.txt
parent4571d64e74dadd1b2169e8cd276f8a298decd5f0 (diff)
downloadprogos-9b19a84ed640cb15e6ca87ddc025c90d78a5fbdc.tar.gz
progos-9b19a84ed640cb15e6ca87ddc025c90d78a5fbdc.tar.bz2
progos-9b19a84ed640cb15e6ca87ddc025c90d78a5fbdc.zip
* fix possible race in thread_set_priority
* fill in same parts of proj1.txt * use thread_get_priority() whenever possible
Diffstat (limited to 'proj1.txt')
-rw-r--r--proj1.txt53
1 files changed, 50 insertions, 3 deletions
diff --git a/proj1.txt b/proj1.txt
index 27b0d17..0cb22e1 100644
--- a/proj1.txt
+++ b/proj1.txt
@@ -35,13 +35,16 @@ http://hynek.me/studies/sched_ausarbeitung.pdf
35>> enumeration. Identify the purpose of each in 25 words or less. 35>> enumeration. Identify the purpose of each in 25 words or less.
36 36
37struct thread: 37struct thread:
38 int is_donated ...flag if threads priority has been donated by another thread 38 int is_donated ...flag if threads priority has been donated by
39 another thread
39 int saved_priority ...saved base priority in case of priority dontation 40 int saved_priority ...saved base priority in case of priority dontation
40 struct list locks ...list of locks the thread currently holds 41 struct list locks ...list of locks the thread currently holds
41 struct lock *blocked_lock ...the lock the thread currently tries to acquire (but hasn't yet) 42 struct lock *blocked_lock ...the lock the thread currently tries to acquire
43 (but hasn't yet)
42 44
43struct lock: 45struct lock:
44 int priority ...the priority of the thread with the highest priority currently acquiring the lock 46 int priority ...the priority of the thread with the highest
47 priority currently acquiring the lock
45 struct list_elem elem ...list element for (struct thread)->locks 48 struct list_elem elem ...list element for (struct thread)->locks
46 49
47struct semaphore_elem: 50struct semaphore_elem:
@@ -51,14 +54,20 @@ struct semaphore_elem:
51>> Use ASCII art to diagram a nested donation. (Alternately, submit a 54>> Use ASCII art to diagram a nested donation. (Alternately, submit a
52>> .png file.) 55>> .png file.)
53 56
57TODO
58
54---- ALGORITHMS ---- 59---- ALGORITHMS ----
55 60
56>> B3: How do you ensure that the highest priority thread waiting for 61>> B3: How do you ensure that the highest priority thread waiting for
57>> a lock, semaphore, or condition variable wakes up first? 62>> a lock, semaphore, or condition variable wakes up first?
58 63
64TODO
65
59>> B4: Describe the sequence of events when a call to lock_acquire() 66>> B4: Describe the sequence of events when a call to lock_acquire()
60>> causes a priority donation. How is nested donation handled? 67>> causes a priority donation. How is nested donation handled?
61 68
69TODO
70
62>> B5: Describe the sequence of events when lock_release() is called 71>> B5: Describe the sequence of events when lock_release() is called
63>> on a lock that a higher-priority thread is waiting for. 72>> on a lock that a higher-priority thread is waiting for.
64 73
@@ -68,11 +77,43 @@ struct semaphore_elem:
68>> how your implementation avoids it. Can you use a lock to avoid 77>> how your implementation avoids it. Can you use a lock to avoid
69>> this race? 78>> this race?
70 79
80thread_set_priority() first changes the priority and then has to either just
81re-sort the ready list or has to decide whether it should yield by comparing the
82priorities of the current thread and the thread with the highest priority in
83the ready list. the gap between changing the priority and doing the other stuff
84raises a few possible races if the timer interrupt triggers in between.
85e.g. no proper sorted ready list, corrupt ready list (wrong internal pointers)
86or the timer interrupt fires after calling list_empty() but before list_front()
87while having only two threads (one active, the other one ready). the scheduler
88then schedules the other thread which runs and perhaps terminates, thus removing
89itself from all lists. after that our thread gets scheduled again and reads from
90an empty list, although it wasn't empty before.
91
92Using a lock instead of disabling the interrupts would require locking the
93access to the ready list everywhere. This doesn't follow the already established
94conventions and would rather be a lot more cpu intensive.
95
71---- RATIONALE ---- 96---- RATIONALE ----
72 97
73>> B7: Why did you choose this design? In what ways is it superior to 98>> B7: Why did you choose this design? In what ways is it superior to
74>> another design you considered? 99>> another design you considered?
75 100
101Acutally we didn't consider any other design. We first tried to solve the
102assignment without pre-planning and just started coding but that failed.
103Afterwards we looked at the various cases, did some drafts and decided on the
104required structure modifications. That did work quite well.
105
106In case of priority donation with locks our design needs only a few cpu
107instructions because we sort the list of locks during insertion and whenever a
108donated priority changes. This allows us to retreive the next donated priority
109with just looking at the first element in the list.
110
111In case of priority donation with semaphores and conditions we can't sort the
112blocked/waiting threads during insertion as their priority may change afterwards
113and we don't have any reference to currently used semaphores/conditions inside
114the thread structure. Thus we simply sort the whole list inside sema_up()/
115cond_signal() before unblocking the next thread.
116
76 SURVEY QUESTIONS 117 SURVEY QUESTIONS
77 ================ 118 ================
78 119
@@ -85,6 +126,10 @@ the quarter.
85>> In your opinion, was this assignment, or any one of the three problems 126>> In your opinion, was this assignment, or any one of the three problems
86>> in it, too easy or too hard? Did it take too long or too little time? 127>> in it, too easy or too hard? Did it take too long or too little time?
87 128
129working on the priority donation without being able to use printf() inside
130lock_acquire()/lock_release() (as printf() requires a lock for the console
131itself) was challenging.
132
88>> Did you find that working on a particular part of the assignment gave 133>> Did you find that working on a particular part of the assignment gave
89>> you greater insight into some aspect of OS design? 134>> you greater insight into some aspect of OS design?
90 135
@@ -92,6 +137,8 @@ the quarter.
92>> future quarters to help them solve the problems? Conversely, did you 137>> future quarters to help them solve the problems? Conversely, did you
93>> find any of our guidance to be misleading? 138>> find any of our guidance to be misleading?
94 139
140do not use printf() inside lock_acquire()/lock_release() :)
141
95>> Do you have any suggestions for the TAs to more effectively assist 142>> Do you have any suggestions for the TAs to more effectively assist
96>> students, either for future quarters or the remaining projects? 143>> students, either for future quarters or the remaining projects?
97 144