final-f09 - Full Name: CSCI 2400, Fall 2009 Final Exam...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Full Name: CSCI 2400, Fall 2009 Final Exam Instructions: Make sure that your exam is not missing any sheets, then write your full name on the front. Put your name or student ID on each page. Write your answers in the space provided below the problem. If you make a mess, clearly indicate your final answer. The exam has a maximum score of 100 points. The problems are of varying difficulty. The point value of each problem is indicated. Pile up the easy points quickly and then come back to the harder problems. This exam is OPEN BOOK. You can not use a computer or calculator. Good luck! Problem Page Possible Score 1 1 10 2 2 20 3 3 10 4 4 20 5 6 20 6 8 20 Total 100
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSCI-2400 -1- November 30, 2010 1. [ 10 Points ] pid_t pid; int counter = 0; void handler1(int sig) { counter ++; printf("counter = %d\n", counter); fflush(stdout); / * Flushes the printed string to stdout * / kill(pid, SIGUSR1); } void handler2(int sig) { counter += 3; printf("counter = %d\n", counter); exit(0); } main() { signal(SIGUSR1, handler1); if ((pid = fork()) == 0) { signal(SIGUSR1, handler2); kill(getppid(), SIGUSR1); // getppid returns the parent PID while(1) {}; } else { pid_t p; int status; counter += 2; printf("counter = %d\n", counter); } } } What is the output of this program? CSCI-2400 -1- November 30, 2010
Background image of page 2
CSCI-2400 -2- November 30, 2010 2. [ 20 Points ] Consider the C program below. (For space reasons, we are not checking error return codes, so assume that all functions return normally.) main() { pid_t pid; int status; printf("1"); if (fork() == 0) { if (fork() == 0) { printf("2"); } } else { printf("3"); if (fork() == 0) { printf("4"); exit(0); } else { printf("5"); } } } printf("6"); return 0; } In the space below, use the < symbol to specify a partial order over each pair of numbers in the possible output(s) of this program. For example, if x should always precede y , and y always precedes z , then write x < y, y < z or just x < y < z . CSCI-2400 -2- November 30, 2010
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSCI-2400 -3- November 30, 2010 3. [ 10 Points ] Assume the following program is executed on a computer that restarts instructions following a segmen- tation fault and that the following assembly code is produced for
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

final-f09 - Full Name: CSCI 2400, Fall 2009 Final Exam...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online