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

• Notes
• 11
• 100% (2) 2 out of 2 people found this document helpful

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

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

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

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; if ((p = wait(&status)) > 0) { counter += 2; printf("counter = %d\n", counter); } } } What is the output of this program? CSCI-2400 -1- November 30, 2010
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 { if ((pid = wait(&status)) > 0) { 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

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

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 main ...
This is the end of the preview. Sign up to access the rest of the document.
• Fall '08
• GRUNDWALD
• Virtual memory, \$16, \$11

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern