What is the output of the following program. In
case you're worried about it, there are no bugs in this
program concerning jumping up the stack.
#include < setjmp.h >
b(int i, jmp_buf j, jmp_buf m)
{
printf(" B: %d\n", i);
if (i % 2 == 1) {
longjmp(m, i+1);
} else {
longjmp(j, i+1);
}
}
a(int i, jmp_buf j)
{
int k;
jmp_buf m;
k = setjmp(m);
i += k;
printf(" A: %d\n", i);
if (i >= 5) longjmp(j, i);
b(i, j, m);
}
main()
{
int i;
jmp_buf j;
i = setjmp(j);
printf("Main: %d\n", i);
if (i >= 5) exit(0);
a(i, j);
}
Question 5
Answer these true/false. Use the answer sheet provided.
A.Malloc() buffers the sbrk() system call.
B. Zombie processes waste a significant amount of memory.
C. My program will typically generate a segmentation violation if I
try to overwrite the instructions in memory.
D. Processes communicate through shared memory
with the fork() system call.
E. You can avoid catching the SIGPIPE signal if you
use threads.
F. My program will typically generate a segmentation violation if I
try to write into memory that is above (less than) the
current value of the stack pointer.
G.Pipe() allows processes to communicate through a buffer
in the operating system.
H.Telnet allows me to write a server program that others
on the Internet may use effectively even if all they know is
my server's host name and port number.