[NSWI004] Third assignment scoring (threads)

Vojtech Horky horky at d3s.mff.cuni.cz
Mon Dec 2 17:27:15 CET 2019


Hello,

we finished checking assignment 03 (treads and cooperative scheduler). 
Again, our comments are in your home directories on lab.d3s.mff.cuni.cz.

You should see the exact commit hash we looked at in the notes. If you 
believe we should have looked at other commit or we overlooked something 
etc., please, contact as as soon as possible.


Generally, the solutions were quite good, the most difficult part seemed 
to be the initial context preparation, the rest was usually straightforward.


One thing was quite common (about one third of the solutions submitted) 
- using allocating lists for keeping queue of ready threads. I 
understand that using the provided list_t/link_t might seem complex at 
first but it has the advantage that you do not need to allocate any 
memory when adding/removing from a list. That is extremely useful when 
the function "cannot fail", i.e. it returns void and the only way how to 
signal problem is by panicking the kernel.

Obviously, the downside is that you have to know in how many lists an 
item might be. Might seem limiting at first but it is actually not a 
problem at all.

I would recommend to switch to using this lists in 
scheduler/synchronizations etc. as it makes the implementation actually 
shorter. As a matter of fact, the implementations that added

link_t ready_list

to thread_t were usually by 50% shorter than the ones with custom lists.


For the following assignments: please, ensure that you *really* 
understand how the context switching works, i.e. where is $sp stored, 
where is stored the rest of the registers etc. For example, there is no 
need to allocate contex_t for the very first context switch, only memory 
for $sp is needed.


There were several cases where your code worked in Rotunda lab but did 
not pass in CI on GitLab. It seems that the older version of MSIM in 
Rotunda is more liberal in several corner cases - please, test your 
solutions on the provided machine lab.d3s.mff.cuni.cz:22004. In all 
cases of this behavior that I have seen, the implementation was 
incorrect and worked in Rotunda by accident only.

As a last thing: if you have problems debugging your implementation, it 
is really useful to ask for consultations several days *before* the 
deadline.

Cheers,
- VH


More information about the NSWI004 mailing list