Information Technology Reference
In-Depth Information
9. Consider the following program:
main(intargc,char**argv){
intchild=fork();
intx=5;
if(child==0){
x+=5;
}else{
child=fork();
x+=10;
if(child){
x+=5;
}
}
}
How many different copies of the variable x are there?
What are their
values when their process finishes?
10. What is the output of the following programs? (Please try to solve the
problem without compiling and running the program.)
//Program1
main(){
intval=5;
if(fork())
wait(&val);
val++;
printf("%d\n",val);
returnval;
}
//Program2:
main(){
intval=5;
if(fork())
wait(&val);
else
exit(val);
val++;
printf("%d\n",val);
returnval;
}
11. Implement a shell using UNIX system calls. Features of your shell can
include pipes, background and foreground tasks, and job control (suspend,
resume, and kill).
Search WWH ::




Custom Search