Unix Network Programming Assignment-2
Winter Semester,Department of Computer Science
University of Hyderabad
Max.Marks : 10					    	Deadline : 10-02-05.

Note : Answer All Questions , Precise Answers will be appreciated.

1. Can a process send a signal to another process that is not in its process group? why or why not?

2.The Canteen at "Gopes", has four employees : (1) Hanuma, who takes customers' orders ; (2) PushpaKumar.SP, who prepares the food; (3) Subhash , who stuffs the food into bags; and (4) Suresh, who gives the bags to the customers and take their money. Each employee can be regarded as a communicating sequential process. What form of interprocess communication do they use? Relate this model to processes in UNIX.

3.When a new process is forked off, it must be assigned a unique integer as its PID. Is it sufficient to have a counter in the kernel that is incremented on each process creation, with the counter used as the new PID? Discuss your answer.

4.program : Parent-child.c #include <stdlib.h> #include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> volatile unsigned long loop = 10000000; void handler (int n){ if (loop > 0) --loop; } static int child (void) { pid_t ppid = getppid (); sleep (1); while (1) kill (ppid, SIGUSR1); return 0; } int main (void) { pid_t child_pid; int r; if ((child_pid = fork ()) == 0) exit (child ()); signal (SIGUSR1, handler); while (loop) sleep (1); r = kill (child_pid, SIGTERM); waitpid (child_pid, NULL, 0); return 0; } a)Explain the above program? b)This program forks a process ,now there are two processes. Changing the priorities of the processes may affect the execution time of the program. So find-out the probable priorities which could result in least execution time. Hint : use nice() system call time and top commands.