Search⌘ K
AI Features

Quiz on Condition Variables

It's quiz time! Answer the following questions to test your knowledge and understanding of the condition variables.

We'll cover the following...
Technical Quiz
1.

What would be printed when running the following code? Assume ‘done’ is a shared variable initialized to 0.

void *child(void *arg) {
    printf("3");
    done = 1;
    return NULL;
}

int main(int argc, char *argv[]) {
    pthread_t p;
    printf("1");
    Pthread_create(&p, NULL, child, NULL);
    while (done == 0); 
    printf("2");
    return 0;
}
A.

123

B.

132

C.

312

D.

321


1 / 5