




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Exam; Class: PARALLEL & DIST COMPUTING; Subject: COMPUTER SCIENCE; University: Georgia State University; Term: Unknown 1989;
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Producer View while (true) { /* produce an item and put in next Produced/ while (count == BUFFER_SIZE) ; // do nothing buffer [in] = nextProduced; in = (in + 1) % BUFFER_SIZE; count++; } Consumer View while (true) { while (count == 0) ; // do nothing nextConsumed= buffer[out]; out = (out + 1) % BUFFER_SIZE; count--; / consume the item in next Consumed }
In the MPI programming we discussed in the class (also showed below), P0 (the id for CPU is 0) is the server who owned the full array and distributed array information to other CPUs. For other CPUs, they wait for receiving those data.
if (id==0) { for(i=0; i<array_size; i++) array[i]=i; /* initialize array/ for(i=1; i<p; i++) MPI_Send(&array[iarray_size/p], /* Start from/ array_size/p, / Message size/ MPI_INT, / Data type/ i, / Send to which process/ MPI_COMM_WORLD); for(i=0; i<array_size/p; i++) local_array[i]=array[i]; } else MPI_Recv(&local_array[0],array_size/p,MPI_INT,0,0,MPI_COMM_WORLD,&stat); Assume we have 8 CPUs, the network of those CPUs looks like below: Instead of using P0 as the only master; we use both P0 and P6 as the masters. (P0 is the master for P through P3; P6 is the master for P4 through P7) Both of them generate the initial array only for their responsibility portion. Write a code similar to I showed you above that matches the criteria. Every line above should have a corresponding line(s) in your answer. (15 pts) If (id==0){ for (i=0; i<array_size/2;i++) array[i]=i; for (i=1; i<4; i++) MPI_Send(&array[iarray_size/p], array_size/p, MPI_INT, i, MPI_COMM_WORLD); for (i=0; i<array_size/p; i++) local_array[i]=array[i]; } If (id==6){ for (i= array_size/2; i<array_size;i++) array[i]=i; for (i=4; i<7; i++) if (i != 6) MPI_Send(&array[iarray_size/p], array_size/p, MPI_INT, i, MPI_COMM_WORLD); for (i=0; i<array_size/p; i++) local_array[i]=array[2 (array_size/p) + i]; } if (id==1 or id==2 or id==3) MPI_Recv(&local_array[0],array_size/p,MPI_INT,0,0,MPI_COMM_WORLD,&stat); if (id==4 or id==5 or id==7) MPI_Recv(&local_array[0],array_size/p,MPI_INT,6,0,MPI_COMM_WORLD,&stat);
6.1 A solution to the critical-section problem must satisfy which three requirements? (6pts) Mutual Exclusion Progress Bounded Waiting 6.2 We consider a system consisting of two processes, P0 and P1, each accessing two semaphores, S and Q, set to the value 1. P0 P Wait(S) Wait(Q) Wait(Q) Wait(S) … … … … … … Signal(S) Signal(Q) Signal(Q) Signal(S) What kind of unwanted situation will happen? (3%) Explain your answer? (3%) Deadlock Occurs 6.3 We consider a system consisting of two processes, P0 and P1, each accessing two semaphores, S and Q, set to the value 1. P0 P Wait(S) Wait(S) Wait(Q) Wait(Q) … … … … … … Signal(S) Signal(Q) Signal(S) Signal(S) What kind of unwanted situation(s) will happen? (4%) Explain your answer? (4%) Starvation (Deadlock) Violate Mutual exclusion
If we applied timestamp-Based Protocols on the following schedule: T0 T1 T Timestamp: 2 4 6. Operation: R(A) R(A) R(A) W(A) W(A) 7.1 If the execution sequence happens like: T0’s R(A) T0’s W(A) T2’s R(A) T2’s W(A) T1’s R(A) Is there any transaction need “Roll Back”? If yes, which one and why? If no, just say no. (3 pts) Yes, T 7.2 If the execution sequence happens like: T0’s R(A) T0’s W(A) T2’s R(A) T1’s R(A) T2’s W(A) Is there any Transaction need “Roll Back”? If yes, which one and why? If no, just say no. (3 pts) No 7.3 If the execution sequence happens like: T0’s R(A) T1’s R(A) T0’s W(A) T2’s R(A) T2’s W(A) Is there any Transaction need “Roll Back”? If yes, which one and why? If no, just say no. (3 pts) Yes, T