代写代考 CMPUT 379, U. of Alberta, course instructor (E. Elmallah). All rights reser

Copyright Notice: Copyright by CMPUT 379, U. of Alberta, course instructor (E. Elmallah). All rights reserved. Do not post any part on a publicly-available Web site.
Question 2 (v2) [10 points]
The following C-code fragment uses POSIX threads:
#define N 10

Copyright By PowCoder代写 加微信 powcoder

pthread_t TID[N];
void *worker(void *arg) {
int workerID= *((int *) arg);
TID[workerID-100] = pthread_self();
int main () {
for (i= 100; i < 100+N; i++) pthread_create(&ntid, NULL, worker, (void *) &i); for (i= 0; i < N; i++) { if (pthread_join(TID[i], NULL)) //exit program on error Answer the following two questions assuming a hypothetical thread environment where each call to function pthread create succeeds and returns to the caller only after creating and running to completion the thread just created. 1. DoeseachcreatedworkerthreadalwaysreceiveauniqueworkerIDvalue? Circleone: 2. Doesthesecondfor-loopalwayssucceedinexecutingalljoinoperations? Circleone: Now, answer the following two questions assuming a realistic UNIX POSIX thread environ- ment running on a multi-core CPU: 3. Repeat question 1 above. Circle one: YES NO 4. Repeatquestion2above.Ifno,outlineapossiblesolutiontothisissue. Circleone: YES Briefly explain your answers. University of Alberta examination University of Alberta examination University of Alberta examination University of Alberta examination University of Alberta examination 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com