CSE3303 (Operating Systems) MT1 - Group A
Nov 17, 2007

Q1 (5 pts): Which one below is false in regards to real-time systems (RTS)?
(a) An Anti-lock Braking System (ABS) is a hard RTS.
(b) A video codec is a soft RTS.
(c) An RTS has OS functions that guarantee timing.
(d) An embedded system is always also an RTS.
(e) A mission critical application basically requires an RTS design.

Answer: d

Q2 (5 pts): Which one of the below is correct about a RAMDISK?
(a) RAMDISK is an area in RAM that appears as a disk drive to user programs.
(b) RAMDISK is another name for RAM on hard disks.
(c) RAMDISK provides many times slower file access than a fast disk drive.
(d) RAMDISK is not available on Linux systems.
(e) RAMDISK is a feature of DVD disk drives that are turned on by the OS.

Answer: a

Q3 (5 pts): Which one of the following is false?
(a) VMware lets us run Linux exe in Windows while Cygwin lets us use Linux src code on Windows.
(b) VMware lets us run Windows exe on Linux.
(c) VMware lets us create a network of virtual PCs on a single PC.
(d) VMware can run Windows XP inside Windows XP.
(e) VMware can run mainframe programs on Linux PCs.

Answer: e

Q4 (5 pts): When a process is not currently executing, there are certain things that the operating system must maintain on behalf of the process, so that when the process starts executing again, it does so correctly. On the list below identify what does not need to be maintained?
(a) Memory range.
(b) Values of registers.
(c) Stack pointer.
(d) Context switch start time.
(e) Instruction pointer.

Answer: d

Q5 (5 pts): DMA means Direct Memory Access. What describes best those that access RAM directly?
(a) Cache
(b) CPU
(c) Hard disk
(d) Peripherals
(e) Graphics adapter

Answer: d

Q6 (5 pts): Which one is not always true in the case of a cooperative multitasking OS?
(a) Processes cannot be preempted.
(b) There is no timer interrupt.
(c) A process can be halted when writing to or reading from the console.
(d) Processes are cooperative so they often yield to each other.
(e) The kernel does not trigger regularly.

Answer: d

Q7 (5 pts): Which of the following is not a plus of using dynamic libraries as opposed to static libraries?
(a) Smaller executables
(b) Quicker run times
(c) Quicker compile times
(d) Quicker program load times
(e) They are all pluses

Answer: b

Q8 (5 pts): Which of the following is false?
(a) Intel's protected mode processors include a dual mode capability.
(b) Real mode is a backwards compatibility mode included in Intel's protected mode processors.
(c) Kernel mode is a subset of dual mode.
(d) Kernel mode is included in Intel's protected mode.
(e) A protected mode Intel processor is simply a dual mode CPU.

Answer: e

Q9 (6 pts): I have a bash script that does a useful job. How am I going to run it on Windows?

Answer: Through Cygwin.

Q10 (6 pts): In a true multi-tasking OS, when does the CPU switch from a user program to the OS. Give me two different cases when this happens.

Answer: (i) When the user program calls an OS function and (ii) when a timer interrupt triggers.

Q11 (6 pts): In the hierarchy of memory types, take DRAM as your reference point and tell me the type of memory that is (i) one level faster (ii) one level smaller (iii) one level slower.

Answer: (i) Cache (SRAM) (ii) Cache (SRAM) (iii) Hard Disk

Q12 (10 pts): I have a task that I do as follows in Windows cmd window.

  C:\mydir> progA > tempfile
  C:\mydir> progB < tempfile

When I just type progA, progA reads from the screen and writes to the screen and so is progB. How should I run these programs in a cmd window so they execute faster in total. Hint: RAM access is faster than HD access, and HD access is faster than screen access.

Answer:

  C:\mydir> progA < infile | progB > outfile

Whatever we are supposed to input to progA on the screen, put them in infile (HD input instead of screen input). Pipe progA's output to progB (RAM Buffer instead of HD access). Redirect progB's output from the screen to outfile (output to HD instead of screen).

Q13 (15 pts): I want to write a code that executes fn1() first and then executes fn2(), fn3(), and fn4() in parallel. Write a code fragment that does this using fork().

Answer:

fn1();
if (fork() == 0) {
  fn2();
} else if (fork() == 0) {
  fn3();
} else {
  fn4();
}

Q14 (15 pts): I have 4 processes running on a quad-core CPU, namely, P1, P2, P3, P4. Each program reads a line from the screen and writes a line to the screen. They process 1 million lines of input in 20, 30, 40, and 50 mins, respectively. When I run them in a pipe (P1|P2|P3|P4) with 3 million lines of input to P1, (i) how long will it take to see output line #10 on the screen? (ii) and how long will it take for the pipe to finish processing all input lines? Hint: Try to turn this into a simple pipelining latency/throughput problem. Ignore the speed-up caused by not writing the output of P1, P2, and P3 to the screen.

Answer: P1 processes one line in 20mins/1M=1200s/1M=1.2ms. Hence, P2 does one line in 1.8ms. P3 in in 2.4ms. P4 in 3ms. Max of these is 3ms. Hence 3ms is the cycle time. (i) #1 line comes out in the sum of 4 numbers (=1.2+1.8+2.4+3ms). That is 8.4ms. (4x3ms=12ms is also acceptable for line #1.) After the 1st line, we will get a new line every 3ms. #10 comes after 8.4+(10-1)*3ms=35.4ms. (ii) for the whole thing, ie. 3M lines, 8.4ms+(3M-1)*3ms=~3M*3ms=9000s=2.5hours.

Q15 (20 pts): We have a true multi-tasking OS on our computer. It has a tq of 3ms. No tq for I/O tasks. Ignore the context switching time. Assume we only have the following two processes running on the OS. P1 is started at t=0 and P2 at t=1ms. Give me the Gantt chart of how the OS schedules the two processes on the CPU and I/O as a table running vertically. Show also the CPUwait and I/Owait queues.

  P1: C2I4C4I2C4
  P2: C2I2C5I5C3

Answer:

  P1: P1C1=2 P1I1=4 P1C2=4 P1I2=2 P1C3=4
  P2: q2C1=2 q2I1=2 q2C2=5 q2I2=5 q2C3=3

t   CPU  CPUwait | I/O  I/Owait
--- ---- ------- | ---- -------
1   P1C1  P1C1
2   "     q2C1
3   q2C1           P1I1
4   "              "
5                  "     q2I1
6                  "     "
7   P1C2           q2I1
8   "              "
9   "     q2C2
10  q2C2  P1C2
11  "     "
12  "     "
13  P1C2  q2C2
14  q2C2           P1I2
15  "              "
16  P1C3           q2I2
17  "              "
18  "              "
19  P1C3           "
20                 "
21  q2C3
22  "
23  "