



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
Material Type: Exam; Professor: McQuain; Class: Operating Systems; Subject: Computer Science; University: Virginia Polytechnic Institute And State University; Term: Unknown 1989;
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




V
IR
G
IN
IA
PO
LYTECHNIC IN ST IT U TE
A N D ST A (^) TE (^) UNIVE
RS
IT
Y U (^) TPROSIM
Instructions:
Name printed
Pledge: On my honor, I have neither given nor received unauthorized aid on this examination.
signed
(a) P1 executes an input operation that requires reading data from a file on disk
(b) P2 executes an arithmetic operation that involves a variable whose value is stored in primary RAM
struct Package { int* L; int sIdx; };
... int main() {
pthread_t hThread[MAX_THREADS]; int* List = new int[OFFSET * MAX_THREADS]; Package P[MAX_THREADS];
for (int p = 0; p < MAX_THREADS; p++) { P[p].L = List; P[p].sIdx = p; pthread_create(&hThread[p], NULL, F, (void*) &P[p]); } Print(cout, List); // print contents of array pthread_exit(0); }
void* F(void* D) {
Package* Data = (Package*) D; for (int Idx = Data->sIdx; Idx < OFFSET * MAX_THREADS; Idx += MAX_THREADS) { Data->L[Idx] = Data->sIdx; } pthread_exit(0); }