Practice Mid-Quarter Examination

Course: Csci 4061

Quarter: Fall 1999

Time Allocated: 75 minutes

Instructions:

1. This is an open book exam. You may consult notes, Unix man-pages , textbook or recommended books. Please do use a any other material or computers.

2. It covers the topics of processes, files and signals. Prerequisite knowledge of C programming language and basic familiarity with Unix operating systems is assumed.

3. There are 5 questions. Budget your time to be able to answer al the questions.

 

Question 1. Determine the trueness of the following statements by marking them "True" or "False". Briefly justify your answers.

1a. Unix 'cp' command can copy a file across two file systems (i.e. two file servers with no shared directory).

 

1b. The special directories "." and ".." are hard links to appropriate directories.

 

1c. A file can have more than two hard links.

 

1d. Deleting a hard link will delete a datafile even if there are other hard links to this file.

 

1e. The process id of a process is always large than that of its parent process.

 

1f. All the processes created by a user are terminated at logout time.

 

------------------------------------------------------------------------------------------------

Q. 2a. What is a 'filter'? Which of the following programs are filters: ls, cat, ps, more, date, du, wc.

 

 

 

 

Q. 2b. Can we redirect the standard input to be terminal-screen and standard output to be the keyboard ? Provide a code-segment to implement it if your answer is affirmative. Provide reasons to justify your answer if it is negative.

 

 

 

 

Q. 2c. What a "daemon" process? How can one terminate it from command line?

 

 

 

 

Q. 2d. Consider the value of "PATH" variable given in Example 3.5 (pp. 84) for user "robbins" to be

/usr/bin:/etc:/usr/local/bin:/usr/ccs/bin:/home/robbins/bin:.

Suppose the user "robbins" renames her solution of one of the last part of homework 2 to be "du" knowing that there is a operating system supplied executable named "du" in /usr/local/bin. Identify the executable (i.e. /usr/local/bin/du OR /home/robbins/hw2/du) will be executed for the folowing commands, assuming present working directory to /home/robbins/hw2:

(i) du

(ii) ./du

 

 

 

 

----------------------------------------------------------------------------------------------------------

Q. 3. Determine the size of largest file allowed by Unix file system. Assume the size of a disk block is 1 Kilobyte (1024 bytes) and the size of a disk block pointer is 4 bytes. Also assume that inodes allow 10 direct pointers to data blocks along a 1-level indirect point, a 2-level indirect pointer and 1 3-level indirect pointer. (Hint: Figure 3.3 and Exercise 3.3, pp. 87-88). Provide brief explanation of your calculations and identify your assumptions.

 

 

 

 

 

 

 

-------------------------------------------------------------------------------------------------------

 

Q. 4. Consider the Program 2.12 (pp. 69). How will the following modifications affect its output? Briefly justify your answers.

(4a) a wait() system call before the final "fprintf" statement.

 

 

 

(4b) a sleep(10) system call before the final "fprintf" statement.

 

 

 

 

(4c) a exec() system call before the final "fprintf" statement with the executable file for program 2.12.

 

 

 

 

--------------------------------------------------------------------------------------------------------------

Q.5 Consider the Program 2.12 (pp. 69). What are the possible outputs of this program in the following situations:

(5a) Its executable is invoked with no command line arguments

 

 

 

(5b) Its executable is invoked with two arguments on command line

 

 

 

 

(5c) Operating system is not able to create new processes during 2nd call to fork(), and the command line agument was 3.

 

 

 

 

(5d) A signal interrupts "fprintf" statement for one of the processes and the command line argument was 3.