Question: Consider a multithreaded system for processing college applications that stores most of its data in memory. It is written in C++ and uses the following



Consider a multithreaded system for processing college applications that stores most of its data in memory. It is written in C++ and uses the following structs: struct Student { pthread_mutex_t lock; string name; Application* current_application; struct Application { pthread_mutex_t lock; Student *student; Academic Year *year; string status; /* one of pending, accepted, admitted, rejected, withdrawn */ struct AcademicYear { pthread_mutex_t lock; set pending, admitted, rejected, withdrawn; }; and has the following functions relevant to the questions below: bool WithdrawPendingStudent (Student *student) { pthread mutex lock(&student->lock); Application *app = student->current application; pthread_mutex_lock (&app->lock); bool result; if (app->status == "pending") { pthread_mutex_lock(&app->year); app->status = "withdraw"; app->year->pending.erase (app); app->year->withdrawn.erase (app); pthread_mutex_unlock (&app->year); result = true; } else { result = false; pthread_mutex_unlock(&app->lock); pthread_mutex_unlock(&student->lock); return result; bool AdmitFirstKPending (AcademicYear *year, int k) { pthread_mutex_lock(&year->lock); for (int i = 0; i pending); year->admitted.insert(app); year->pending.erase (app); pthread mutex lock(&app->lock); app->status = "admitted"; pthread mutex_unlock(&app->lock); pthread mutex unlock (&year->lock); Question 3 (1 points): (see above) Two simultaneous calls to WithdrawPending Student and AdmitFirstKPending sometimes deadlock. When this occur, the thread calling WithdrawPendingStudent() can be holding the lock in a while the thread calling AdmitFirstKPendingo is trying to acquire the same lock. Select all that apply A. O Application struct B. Academic Year struct C. Student struct Comments: Question 4 (1 points): (see above) Two simulatenous calls to WithdrawPending Student) and AdmitFirstKPending sometimes deadlock. When this occur, the thread calling AdmitFirstKPending() can be holding the lock in a while the thread calling WithdrawPendingStudent() is trying to acquire the same lock. A. Student struct B. O Academic Year struct C. O Application struct Consider a multithreaded system for processing college applications that stores most of its data in memory. It is written in C++ and uses the following structs: struct Student { pthread_mutex_t lock; string name; Application* current_application; struct Application { pthread_mutex_t lock; Student *student; Academic Year *year; string status; /* one of pending, accepted, admitted, rejected, withdrawn */ struct AcademicYear { pthread_mutex_t lock; set pending, admitted, rejected, withdrawn; }; and has the following functions relevant to the questions below: bool WithdrawPendingStudent (Student *student) { pthread mutex lock(&student->lock); Application *app = student->current application; pthread_mutex_lock (&app->lock); bool result; if (app->status == "pending") { pthread_mutex_lock(&app->year); app->status = "withdraw"; app->year->pending.erase (app); app->year->withdrawn.erase (app); pthread_mutex_unlock (&app->year); result = true; } else { result = false; pthread_mutex_unlock(&app->lock); pthread_mutex_unlock(&student->lock); return result; bool AdmitFirstKPending (AcademicYear *year, int k) { pthread_mutex_lock(&year->lock); for (int i = 0; i pending); year->admitted.insert(app); year->pending.erase (app); pthread mutex lock(&app->lock); app->status = "admitted"; pthread mutex_unlock(&app->lock); pthread mutex unlock (&year->lock); Question 3 (1 points): (see above) Two simultaneous calls to WithdrawPending Student and AdmitFirstKPending sometimes deadlock. When this occur, the thread calling WithdrawPendingStudent() can be holding the lock in a while the thread calling AdmitFirstKPendingo is trying to acquire the same lock. Select all that apply A. O Application struct B. Academic Year struct C. Student struct Comments: Question 4 (1 points): (see above) Two simulatenous calls to WithdrawPending Student) and AdmitFirstKPending sometimes deadlock. When this occur, the thread calling AdmitFirstKPending() can be holding the lock in a while the thread calling WithdrawPendingStudent() is trying to acquire the same lock. A. Student struct B. O Academic Year struct C. O Application struct