<div dir="ltr"><div>Hello,</div><div>I have two questions pertaining to assignment 03 - about locks and finished threads.</div><div><br></div><div>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?</div><div><br></div><div>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... <br></div><div><br></div><div>Please let me please know if I am missing something obvious :)<br></div><div>Thanks for the reply.</div><div>Best regards,</div><div>Krystof Hruby<br></div></div>