CSCI 4534 - Operating Systems

Final Examination

There are 10 problems in this final examination. Some are easier than others, so read through all of them before you decide how to allocate your time to maximize your score. Partial credit will be given when appropriate, so it is a reasonable strategy to do partial work on all the problems instead of dedicating too much time on a select few.

The total points you can earn is 110. The examination is graded on a scale of 0-100, so you have 10 points of optional extra credit.

You have 4 hours to compose your responses on the provided blank sheets of paper; use additional sheets of paper, as needed. Write your name and signature on the header of every sheet of paper. Answer sheets without your name and signature will not be graded.

Write clearly, and use good English. Illegible or unclear responses will not receive full marks. You may use pencil or pen.

You may use the classroom computer only to review lecture material, available in the form of powerpoint presentations, or to access personal notes from a floppy or USB drive (but no other files). Only one student may use the computer at a time. Remember to remove your floppy or USB drive when you step away from the computer.

This is an open book examination. You may refer to your textbook and personal notes which you took during the course at will, as well as the classroom computer in the manner described above. You may not use any other written or electronic materials, including but not limited to personal laptops, calculators, or cell phones.

Do not sit right next to another student, especially one who was your study partner. Similar answers are natural between study partners, so sitting far apart is the best way to prevent concerns regarding possible Honesty Code violations.

The Honesty Code of UHCL states: I will be honest in all my academic activities and will not tolerate dishonesty. You should work on this examination completely on your own, without consulting with any other student; you should also report any violations you observe. Your signature on your answer sheets indicates you agreement to abide by this policy during this examination.


Processes

Consider the following C program:
int main(int argc, char **argv)
{
  printf("%d\n",fork());
}
This program is being executed under a process whose ID is 10. Assume that the operating system will assign ID 11 to the next process created. Each of the following are suggested as possible outputs on the terminal window from which process 10 was started; some suggestions are feasible (i.e. may happen), some are not (i.e. they can never happen). For each suggestion, state whether it's feasible or not and justify your answer.
  1. [1 point]
    10
    11
    
  2. [1 point]
    11
    10
    
  3. [1 point]
    0
    11
    
  4. [1 point]
    11
    0
    
  5. [1 point]
    0
    10
    
  6. [1 point]
    10
    0
    
  7. [2 points]
    011
    
  8. [2 points]
    10
    1
    

Threads

[6 points] Under pure user threads, the user-level scheduler cannot preempt one thread to let another run. Instead, a thread has to explicitly yield control of the CPU to the user-level scheduler (via a user-level function call into a user-level library) who can then pass control to another user-level thread. For example, the Pthreads C-language API includes the function
void pthread_yield();
to achieve this end. Java green threads are also pure user threads. However, there is no method like the one above in the Thread class, nor anywhere else in the JDK. Does that mean that your Java green threads can never be preempted? If they cannot, explain why not; if they can, explain at what execution points preemption of a Java thread is possible.

[2 points] If a Java green thread blocks on I/O, can another green thread of the same program take over the CPU? Assume the JVM is assigned a single kernel thread. Justify your answer.

[3 points] List the three ways in which user-level threads can be mapped to kernel-level threads, and concisely list the relative advantages of each technique.


CPU scheduling

Consider a set of processes with the following characteristics:

Process Burst time Arrival time Initialization time
P1 4 0 1
P2 7 1 1
P3 3 2 2
P4 9 3 2

The process initialization time is the cummulative time the process needs to spend executing on the CPU from the moment it first starts using the CPU, and until it produces its first response. For example, with FCFS scheduling,

The Gantt chart is:

0........3 4........10 11........13 14........22
P1 P2 P3 P4

The average response time for the above process schedule under FCFS scheduling is (1+4+11+13)/4=7.25.


Process sychronization

[11 points] Consider the following proposed solution to the critical section problem for n processes. Determine whether it is a correct one, and then justify your answer in the following manner: The proposed solution is listed below:

Deadlocks

Consider the following snapshot of a system that employs deadlock avoidance via the banker's algorithm:
  1. [1 point] What are the contents of the Need matrix?
  2. [5 points] Is the system in a safe state? If so, derive a safe sequence and justify your derivation; if not, explain why not.
  3. [5 points] Assuming no fairness policy, can the system in the above state grant immediately a request from process P1 for (0,4,2,0)? Justify your answer and show your work.

Memory management

Consider a memory management model that uses segmentation with paging in the same style as PhysicalController from assignment 2. Here are the lengths of the five address parts: Answer the following questions, and justify all your answers.
  1. [1 point] What is the size of a frame, in bytes?
  2. [1 point] What is the maximum number of segments a process can have?
  3. [1 point] What is the maximum size of a segment, in bytes?
  4. [1 point] What is the maximum number of page tables a process can have?
  5. [1 point] What is the maximum number of entries that a page table can contain?
  6. [2 points] What is the maximum size of the address space of a process, in bytes?
  7. [1 point] If a process issued linear addresses (instead of logical addresses), what would be the maximum size of its address space, in bytes?
  8. For the following two questions, assume that we cannot change the number of bits used for d or the segment number and segment offset. However, we can choose the number of bits used for p1 and p2. Also, we assume that all processes always have an address space of maximum size.

    [2 points] If we want to minimize the size of kernel data structures, what is the optimal choice for the number of bits used for p1?

  9. [1 point] Given this choice for p1, what must be the number of bits used for p2?

Virtual memory

[11 points] The second-chance (SC) algorithm is an LRU approximation algorithm. Demonstrate by example that it does not always produce the same result as the LRU algorithm. Specifically, come up with a page-reference string and number of frames, and show how SC and LRU produce a different final set of pages in the frames for the same string; draw diagrams like the ones on figures 10.9, 10.11, and 10.12 of your textbook. You may initialize the SC circular queue pointer to point at any frame, but you have to state your choice clearly.

File systems

[11 points] Consider a disk drive formatted by MS-DOS. It contains two files: Show the complete contents of the FAT. Assume that the disk blocks set aside for file data are numbered 0 through 9. Use -1 to mark unused FAT entries and -2 as the end-of-file marker.

RAID

Consider 4 identical disk drives whose capacity is 128GB each. We want to build a RAID system using those drives. What is the maximum capacity of the RAID system as a whole (i.e. of the new single logical drive formed by combining the individual disk drives into a RAID) under each of the following RAID levels? If the capacity of each block is 4KB, how many blocks store parity information under each of the following RAID levels?

Security

Consider a computer system with the following characteristics: One day, John goes to his office, and logs into this computer system via his terminal. At noon, he meets Austin for lunch where John eats a lot of mít. After lunch, they return to John's office. A few minutes into their meeting, John suddenly has to leave his office to go to the restroom. Austin is left alone in the office while John is gone, and can therefore use John's terminal for less than 2 minutes.

[11 points] During John's absence, can Austin take a series of non-destructive actions that will eventually lead to him receiving a copy of Microsoft's budget? If so, list those actions; if not, explain why not.


© 2004 Apostolos Lerios