Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

uppose we can have at most five threads in the critical section at any one e. Co

ID: 3699347 • Letter: U

Question

uppose we can have at most five threads in the critical section at any one e. Complete the following Go program so that it ensures that there are five threads (in this case, the// variables data section in the nain function, the entry and eit se work function, and the arguments and parameters list definition, respectively. Do not use busy waiting. at most goroutines) in the critical section at once. Specifically sections in the for the work function call and 1 var num_goroutines 100 2 varwg=&sync;,WaitGroup() 4 func work( 6 1 10 11 II 12 13 / 14 15 16 17 18 g.Done () 19 20 21 func main) f 22 Add (100) 23 24 I variables 26 27 30 spawns and starts 100 goroutines i++f 31 for i 0 i

Explanation / Answer

//at entry section lock should be aquire

//at exit section lock should be released

// inside the the work function

work( sem_t limit)