CS计算机代考程序代写 Q1

Q1
1 Point
How many “hello” output lines does this program print?
2 3 4 5
Q2
1 Point
. How many “hello” output lines does this program print?

4 6 8  10
Q3
1 Point
What is the output of the following program?

 counter = 0  counter = 1  counter = 2  counter = 3
Q4
5 Points
Consider the following program:
(fflush(stdout) makes sure that the earlier “printf” results will be immediately appear in the output stream)
int main () {
pid_t c1, c2; int status;
printf(“0”); fflush(stdout);
c1=fork(); if(c1==0){
printf(“1”); fflush(stdout);

exit(0); }else{
c2=fork(); if(c2==0){
printf(“2”); fflush(stdout);
exit(0); }
}
waitpid(c2, &status, 0); printf(“3”); fflush(stdout);
return 0; }
Determine which of the following outputs are possible when this program finishes.
Q4.1
1 Point
0123
 Possible
 Not possible
Q4.2
1 Point
0213
 Possible
 Not possible
Q4.3
1 Point

0132
 Possible
 Not possible
Q4.4
1 Point
0231
 Possible
 Not possible
Q4.5
1 Point
000123
 Possible
 Not possible
Q5
1 Point
If an exception occurs while executing an instruction I, what could be the next instruction to execute at user space?
 The instruction right after I
 I itself
 An instruction outside the program of I
 The above three scenarios are all possible

Leave a Reply

Your email address will not be published. Required fields are marked *