Home | CS439 |
char a[100]; thread_func(int r, char ** g) { int d; static double b; char * s = "boo"; char * p; p = malloc(300); return 0; }Identify the segment in which each variable resides and indicate if the variable is private to a thread or shared amongst threads.
main(int argc, char**argv) { int child=fork(); int c=5; if(child==0) { c+=5; } else { child=fork(); c+=10; if(child) c+=5; }How many different copies of the variable c are there? What are their values?
The agent places two of the ingredients on the table. The smoker who has the remaining ingredient then makes and smokes a cigarette, signaling the agent on completion. The agent then puts out another two of the three ingredients, and the cycle repeats.
Assume the agent calls the procedure:
void chooseIngredients(int *paper, int *tobacco, int *match);to randomly select 2 of the 3 ingredients. The routine randomly sets 2 of the values to "1" and one of the values to "0". You don't have to write this routine.
Write a program to synchronize the agent and smokers.
Variable Name Variable Type Initial Value Description