1. Homepage
  2. Exam
  3. [2021] PSU - CMPSC 473 Operating Systems - Final Exam - Q13 Multi-threaded Program

[2021] PSU - CMPSC 473 Operating Systems - Final Exam - Q13 Multi-threaded Program

This question has been solved
Engage in a Conversation

Q13 CourseNana.COM


CourseNana.COM

Consider the multi-threaded program below and choose the options that correctly minimum and maximum possible values of X printed by the thread A and B. To get points, you must show thread interleavings resulting in each of these outcomes in the text-box for the next problem. A lucky guess with an incorrect interleaving will get you 0 points. CourseNana.COM

  CourseNana.COM

1. int X = 0; CourseNana.COM

  CourseNana.COM

2. void* printX(void* data) { CourseNana.COM

3. X = X + 4; CourseNana.COM

4. printf("thread %s %d \n",(char*)data,X); CourseNana.COM

5. X = X + 2; CourseNana.COM

6. } CourseNana.COM

7. CourseNana.COM

8. int main() { CourseNana.COM

9. pthread_t thread_id[ 2 ]; CourseNana.COM

10. X++; CourseNana.COM

11. pthread_create(&thread_id[ 0 ], NULL, printX, "A"); CourseNana.COM

12. X = X + 3; CourseNana.COM

13. pthread_create(&thread_id[ 1 ], NULL, printX, "B"); CourseNana.COM

14. X = X + 2; CourseNana.COM

15. pthread_join(thread_id[ 0], NULL); CourseNana.COM

16. pthread_join(thread_id[ 1], NULL); CourseNana.COM

17. } CourseNana.COM

  CourseNana.COM

  CourseNana.COM

the minimum possible value of X printed by thread A is CourseNana.COM

the maximum possible value of X printed by thread A is CourseNana.COM

the minimum possible value of X printed by thread B is CourseNana.COM

the maximum possible value of X printed by thread B is CourseNana.COM

Get the Solution to This Question

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
The Pennsylvania State University代写,PSU代写,CMPSC473代写,Operating Systems代写,The Pennsylvania State University代编,PSU代编,CMPSC473代编,Operating Systems代编,The Pennsylvania State University代考,PSU代考,CMPSC473代考,Operating Systems代考,The Pennsylvania State Universityhelp,PSUhelp,CMPSC473help,Operating Systemshelp,The Pennsylvania State University作业代写,PSU作业代写,CMPSC473作业代写,Operating Systems作业代写,The Pennsylvania State University编程代写,PSU编程代写,CMPSC473编程代写,Operating Systems编程代写,The Pennsylvania State Universityprogramming help,PSUprogramming help,CMPSC473programming help,Operating Systemsprogramming help,The Pennsylvania State Universityassignment help,PSUassignment help,CMPSC473assignment help,Operating Systemsassignment help,The Pennsylvania State Universitysolution,PSUsolution,CMPSC473solution,Operating Systemssolution,