单选题:```
```
#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 .
What is the value range of the variable ptr after the statement(2)is executed?@[B](1)
A. 0x00800000 - 0x00804000
B. 0x0090000 - 0x00906000
C. 0xb8000000 - 0xb80fffff
D. 0x20000000 - 0x2000fffff
A.0x00800000 - 0x00804000
B.0x0090000 - 0x00906000
C.0xb8000000 - 0xb80fffff
D.0x20000000 - 0x2000fffff
答案:B
#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 .
What is the value range of the variable ptr after the statement(2)is executed?@[B](1)
A. 0x00800000 - 0x00804000
B. 0x0090000 - 0x00906000
C. 0xb8000000 - 0xb80fffff
D. 0x20000000 - 0x2000fffff
A.0x00800000 - 0x00804000
B.0x0090000 - 0x00906000
C.0xb8000000 - 0xb80fffff
D.0x20000000 - 0x2000fffff
答案:B