Feb. 18, 2009
CS354 First exam
Your name: _________________________
1. True/False Questions (write F or T) (10 points, 1 point each)
__ The linker adds shared libraries (.so files) to the executable file when it builds a program.
__ In a 32-bit architecture, a pointer to an array of pointers defined as “char *(*a)[5]”. If “a” has the value 1000, “a+1” points to the address 1020.
__ In Preemptive Scheduling a context switch happens only when the running process goes to a waiting state or when the process gives up the CPU voluntarily.
__ An operating system is a program that can be compiled with a normal compiler.
__ A call to strcat(a,b) will allocate space with a number of bytes equal to the length of string "a" plus the length of string "b" plus 1.
__ A canary is a process that gets killed and transformed into a zombie.
__ The data section stores initialized global variables.
__ A signal that isn't specifically handled by a process, is automatically ignored.
__ A context switch is always the result of an interrupt.
__ Asynchronous I/O relies on polling.
Short Questions
2. Exec calls
a) Compare “exec” calls variants by identifying 2 features that can make them more or less safe to use, and explain why (you don't need to remember the exact name of the “exec” call variants, as long as you can discuss the features). (2 points)
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
b) Which feature is common to all “exec” calls that makes them safer to use than using “eval(command)” or “system(const char *command)” calls? (1 point)
_________________________________________________________________________________
3. Give 3 reasons why syscalls need to switch into kernel mode. (3 points)
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
4. Describe how a process needing to perform I/O operations is managed by the operating system. Hint: highlight parallel operations and process state, and use interrupts. (4 points).
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
5. List 4 examples of information that is stored in a process entry in the process table. (4 points).
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
6. An interrupt can happen at anytime. What must be done before and after servicing the interrupt, to make sure that the program can continue to run properly ? (3 points)
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
7. Identify 2 trust boundaries in a computer, focusing on the operating system or the hardware. Briefly explain which side of the boundary is more or less trusted. (2 points)
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
_________________________________________________________________________________
8. Draw the simplified process state transition diagram that was presented in class. (4 points)
9. Scheduling Policy. For the following processes, draw a (collapsed) Gantt chart, and calculate the turnaround (completion) time for each execution in the different scheduling policies. Then calculate the average turnaround (completion) time. Assume quantum length T=3 ms, and that they are ordered in the ready queue with p1 being first, then p2, etc... (9 points)
Process Burst timePriority
p125 3
p25 1
p320 2
p45 5
a) Shortest Job First (SJF)
b) Round Robin, preemptive
c) Priority scheduling (convention: lowest number is greatest priority)
10. Consider this program:
void my_funk(int a[], int n)
{
int i, *p, *q, value;
for (i = 0; i < n; i++)
{
p = a + i;
value = *p;
q = p - 1;
while (q >= a && *q > value)
{
*p = *q;
p = q;
q--;
}
*p = value;
}
}
a) Rewrite it using array indexing instead of pointers. (6 points)
b) What does it do? (2 points)