

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Hsu; Class: UNIX System Programming; Subject: Computer Programming; University: Florida Atlantic University; Term: Spring 2008;
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


This is an OPEN textbook, but CLOSED notes test. You may consult your textbook for syntax questions. No other reference materials are allowed to be open. NO exchange of information is allowed among students. Write your answers on the space provided.
a) int (* fa )(int);
fa is a pointer to an integer function that takes one integer parameter.
b) int (* fb (int, int (* fbb )(void)))(int, int);
fb is a function that takes two arguments (int & function) and returns a pointer to an integer function with two integer arguments.
fbb is a pointer to an integer function that takes no argument.
c) int * fc (int i, int j);
fc is a function with two integer arguments, and returns an integer.
a) signal() To set up a signal handler
b) kill() To send a signal
c) alarm() To setup an alarm clock
d) pause() To suspend the execution of a process
e) waitpid() To wait for a specific child (pid) to finish
1 #include <stdio.h> 2 #include <sys/types.h> 3 int global = 10; 4 main(void) 5 { 6 void func1(void), func2(void); 7 func1(); 8 func2(); 9 } 10 void func1(void) 11 { 12 int i_local = 20; 13 static int s_local = 30; 14 if (fork()) { /* assume fork() is executed successfully */ 15 wait((char *)0); 16 printf("i_local = %d\n", i_local); 17 printf("s_local = %d\n", s_local); 18 return; 19 } 20 else { 21 global++; 22 i_local++; 23 s_local++; 24 } 25 } 26 void func2(void) 27 { 28 printf("global = %d\n", global); 29 }
global = 11 i_local = 20 s_local = 30 global = 10