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

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

This question has been solved
Engage in a Conversation

Question 13


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

CourseNana.COM

int X = 0; CourseNana.COM

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

X = X + 4; CourseNana.COM

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

X = X + 2; CourseNana.COM

} CourseNana.COM

int main() { CourseNana.COM

pthread_t thread_id[ 2 ]; CourseNana.COM

X++; CourseNana.COM

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

X = X + 3; CourseNana.COM

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

X = X + 2; CourseNana.COM

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

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

} CourseNana.COM

CourseNana.COM

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

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


CourseNana.COM

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


CourseNana.COM

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


CourseNana.COM

  CourseNana.COM

Get the Solution to This Question

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
PSU代写,CMPSC 473代写,Operating Systems代写,The Pennsylvania State University代写,Exam Help代写,PSU代编,CMPSC 473代编,Operating Systems代编,The Pennsylvania State University代编,Exam Help代编,PSU代考,CMPSC 473代考,Operating Systems代考,The Pennsylvania State University代考,Exam Help代考,PSUhelp,CMPSC 473help,Operating Systemshelp,The Pennsylvania State Universityhelp,Exam Helphelp,PSU作业代写,CMPSC 473作业代写,Operating Systems作业代写,The Pennsylvania State University作业代写,Exam Help作业代写,PSU编程代写,CMPSC 473编程代写,Operating Systems编程代写,The Pennsylvania State University编程代写,Exam Help编程代写,PSUprogramming help,CMPSC 473programming help,Operating Systemsprogramming help,The Pennsylvania State Universityprogramming help,Exam Helpprogramming help,PSUassignment help,CMPSC 473assignment help,Operating Systemsassignment help,The Pennsylvania State Universityassignment help,Exam Helpassignment help,PSUsolution,CMPSC 473solution,Operating Systemssolution,The Pennsylvania State Universitysolution,Exam Helpsolution,