Merge 'task1/priority-donation' into 'master' #14
Reference in New Issue
Block a user
No description provided.
Delete Branch "task1/priority-donation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Submitting a working implementation of priority scheduling supporting priority donation. All test case passes. All race conditions have been handled. Code was reviewed for style. - Saleh and Themis.
requested review from @gk1623
assigned to @sb3923
assigned to @td1223 and unassigned @sb3923
assigned to @sb3923 and unassigned @td1223
approved this merge request
mentioned in commit
0cbae2a2e5For the future, lets try to not do such changes
117-123 (with curlies) should be indented (pintos style).
Imo the underscore is too vague about what it means, perhaps something like this would be better?
I see this is used only for a
list_max (...)to get the maximum priority, so afaik order of same priority threads does not matter. So, can we not just instead dolist_min (...)usingpriority_more, and remove this function entirely?Why?
Can a thread be in multiple donor lists? If yes, then we can't do this.... one
struct list_elemcan only be a member of one list at a single time.Other than the comments, looks very good, thanks guys!
I've tried to think about how we can reduce disabling interrupts, but couldn't come up with anything. You've probably thought this aspect through a lot as well, right?
We did indeed. Technically it is possible in certain cases, but it would be extremely ugly (module separation / editing the code for other structs / unnecessary fields in struct thread etc).
Also, the design document only asks about one case in particular and whether it can be done without disable interrupts. So this also sort of gave us a bit of confidence that this is probably the only place where using them may have been an option.
saleh claimed this is the style they use in other list comparison functions/elsewhere in the codebase, so I guess it's good (?)
Agreed.
Yeah you're right. I swear we fixed this one but probably never pushed it. To Be Fixed later today.
we did this originally but felt we might get marked down for lack of clarity/ abusing functions. it's probably easier to understand that max gives maximum, min gives minimum, especially since the functions say the expect a 'list_less' function, but i dont mind reverting
Yes it is the style they follow hence the naming. So this is consistent with PintOS.
Yeah we had
list_min (..., priority_more, ...)in the entire codebase before. But it was really confusing and led to many errors that were only caught when debugging later on in the project. I feel it is better to keep both. It is a private function anyway.I believe we are more likely to be marked down for abusing the naming, and using min when want the max (ugly code) than we are if we keep both (if this is even considered an instance of duplication).
this isn't our code iirc, so best left alone
Perhaps we could at least re-used
priority_morewithindonor_priority_less, rather than rewriting pretty much exactly the same code?ie.
return !priority_more(a_, b_);224 is an addition from this PR, so this is definitely our code
shouldn't be possible. a thread is only a donor if it waits for the lock of the donee. but you can only be waiting for one lock at a time.
This was added in the final code base.
I think it should be there yes! It is also possible to add a simple check of the effective priority (which is the same as the base one in this case).
One thing worth considering is whether it can be called from within an interrupt handler? I dont think so but maybe worth just double checking.
I'm convinced that it's safe, I just don't really understand why you added it.
No we can't unfourtnately. We basically did this initially which was only found after hours of debugging.
This is because the
elemthey use is different! So the list_max and list_min do not give the expected values but seemingly random when used with the wrong comparison functionOh right I see, makes sense.
If the newly created thread has a higher priority then the current running thread should yield the processor to that thread. At least this is what were thinking.
Exactly what @td1223 said. The donors are removed when a lock is released (possibly moved), so yes they can always be in one donors list at a time.
yeah my bad I forgot I added this as one of the first commits and that's the reasoning. this aspect is tested in the suite too
Since we have both the
parent_threadandt(hread) anyway, I think we should do a check for that, so that we're not yielding for no reason, what do you think?ie.
Yeah I am happy with adding this simple check 😄
I shall add it later on with the other fix.
mentioned in merge request !20