[NSWI004] a03 - locks and finished threads

Kryštof hrubý hrubyk97 at gmail.com
Mon Nov 16 14:57:57 CET 2020


Hello,
I have two questions pertaining to assignment 03 - about locks and finished
threads.

It seems to me that any code working with data structures of threads and
scheduler is a possible critical section (e.g. thread_yield - depends on
implementation but the same thread can be started at the same time on
multiple cpus?). Therefore, we are supposed to implement spin locks in this
assignment, right? I am not sure if it is so clear we should do it since it
is not mentioned in the assignment instructions and nobody has asked about
it. If so, we can use any gcc built-in functions, right? Are there any good
ways to debug that the locking works correctly?

Moving on to my other question, is it necessary to keep track of all
finished threads (for a given process)? It seems weird to me since creating
a lot of threads can make the kernel run out of memory and it seems not
very memory efficient but how else can we determine that a particular
thread has finished? If thread A wants to wait for thread B via
thread_join(B) and B finishes sooner than thread A even calls
thread_join(B), then how can the kernel tell that A can continue...

Please let me please know if I am missing something obvious :)
Thanks for the reply.
Best regards,
Krystof Hruby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://d3s.mff.cuni.cz/pipermail/nswi004/attachments/20201116/5f70c605/attachment.htm>


More information about the NSWI004 mailing list