-->
当前位置:首页 > 题库

单选题:```

Luz5年前 (2021-05-10)题库551
```
#include
int count = 0;
int main()
{
int *ptr = 0;
int pid = getpid();
if (pid = fork()) {
wait( );
ptr = (int *) malloc(sizeof(int)); (1)
count++;
*ptr = count;
printf(“this: %d\n”, *ptr);
} else {
count++;
ptr = &count; (2)
printf(“that: %d\n”, *ptr);
}
}
```

The program is compiled and linked by gcc as an ELF format executable program. When the program is executed, assume that the text section occupies the address space 0x00800000 - 0x00804000, the data section occupies the address space 0x0090000 - 0x00906000, the user stack occupies the address space 0xb8000000 - 0xb80fffff, the heap occupies the address space 0x20000000 - 0x2000fffff. The PID of the parent process is 101,while the PID of the child process is 102 .

In what order will the statements (1)and (2)be executed?@[B](1)
A. (1) prior to (2)
B. (2) prior to (1)
C. (1) and (2) will be executed concurrently
D. uncertain



A.(1) prior to (2)
B.(2) prior to (1)
C.(1) and (2) will be executed concurrently
D.uncertain


答案:B