MT1 Sample Qs and Solutions

I have jumps in question numbers because I've removed the linker questions.

Q1: What is a real-time system (RTS)? What is a hard RTS? What is a soft RTS? What is different between the two? Give an example of to both hard and RTS.


Q2: Which one of the below is correct about a RAMDISK?
(a) RAMDISK is a hard disk with a RAM cache.
(b) RAMDISK is another name for USB sticks.
(c) RAMDISK provides many times faster file access than a regular disk drive.
(d) RAMDISKs are not available on UNIX systems.
(e) RAMDISK is a feature of some HDs that needs to be turned on in the OS.


Q3: What does PCB stand for?


Q4: What is a RAMDISK? What is it useful for?


Q5: What is interleaving?


Q6: What is the distinguishing property of hard real-time systems? Give an example of a hard real-time system.


Q7: What is different between hard and soft real-time systems? Give an example of a soft real-time system.


Q8: We have 100 processes. Pi arrives at t=2i. P0's CPU burst is 200ms. Other processes all have a burst of 20ms. The OS is doing a RR (round robin) scheduling with a time quantum of tq. What is the average completion time (a) when tq=10 (b) when tq=100.


Q10 (16 pts): Write a C code that creates exactly 769 child and grandchild processes. Write it so that it creates them the quickest way (ie. the most parallel). No shared memory or semaphores are allowed.


Q11: Which one below is not a UNIX shell?
(a) csh
(b) tcsh
(c) zsh
(d) bash
(e) powsh


Q12: Timer interrupt preempts cooperative multitasking processes. True or false?


Q13: In Windows let's say I just wrote and compiled a program in C:\myprogs\mynewprog\bindir directory. I want to be able to run this program from a cmd window while in other directories without typing the path to the executable. How do I do this?


Q15: Which one below is not a UNIX shell?
(a) csh
(b) tcsh
(c) zsh
(d) cmdsh
(e) bash


Q17: 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) Information about file access status.
(b) Values of registers.
(c) Context switch time.
(d) Stack pointer.
(e) Program counter.


Q18: DMA means Direct Memory Access. What is it that accesses memory directly?
(a) CPU
(b) Cache
(c) Hard disk
(d) Peripherals
(e) Graphics adapter


Q19: Which one is not 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 doing stdio.
(d) Processes are cooperative so yield to each other.
(e) The kernel does not trigger regularly.


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


Q21: Which of the following is false?
(a) Protected mode is a superset of dual mode.
(b) Dual mode is a subset of protected mode.
(c) Kernel mode is a subset of dual mode.
(d) Kernel mode is a subset of protected mode.
(e) Protected mode is a subset of dual mode.


Q23: 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) Interrupt history.
(b) Information about file access status.
(c) Values of registers.
(d) Program counter.
(e) Stack pointer.


Q25: 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 the things that the operating system must maintain on behalf of a non-executing process.

a.Interrupt vector.
b.Information about open files.
c.Register state.
d.Timer interrupt.
e.Control status register.
f.Console interrupt.
g.Memory management information (e.g. main_memory pointer).
h.Kernel/User mode bit.
i.Context switches.
j.Information about CPU speed.
k.The process' cache.
l.The PC location of the process' next instruction.
m.Turnaround time.
n.Disk controller information.

Q26: Consider the following C program which spawns a child process. Tell me what the parent process prints; then tell me what the child process prints.

int main(int argc, char **argv)
{
  int pid, x=5;

  pid = fork();
  x = x+1;

  if (pid == 0)
  { /* child */
    printf("x1=%d\n", x);
    printf("x2=%d\n", x);
    printf("x3=%d\n", x);
    sleep(1);
    printf("x4=%d\n", x);
  } else {
    /* parent */
    printf("x5=%d\n", x);
    x = 3;
    sleep(1);
    printf("x6=%d\n", x);
  }

  printf("x7=%d\n", x);
}

Q27: Protecting the OS is crucial to ensuring that the computer system operates correctly. Provision of this protection is the reason for dual-mode operation, memory protection, and the timer. To allow max flexibility, however, you should also place minimal constraints on the user. The following is a list of instructions that are normally protected. What is the minimal set of instructions that must be protected?

a. Change to user mode.
b. Change to monitor mode.
c. Read from monitor memory.
d. Write into monitor memory.
e. Fetch an instruction from monitor memory.
f. Turn on timer interrupt.
g. Turn off timer interrupt.

Q28: What is BIOS?


Q29: What is DMA?


Q30: Write C code that creates 5 child processes including grandchildren if any.


Q31: How many child processes does the below code spawn?

  fork();
  fork();
  fork();
  fork();
  fork();

Q32: What is cooperative multitasking? And how is it different from preemptive (ie. regular) multitasking?


Q33: Give me the memory hierarchy starting from near the CPU and going to periherals in today's computers.


Q34: Compare compiling with static libraries and dynamic libraries in terms of their pros and cons.


Q35: What is the equivalent of .DLL in Linux?


Q36: Where do Windows and Linux look for shared libraries?


Q37: What does the "make" program do?


Q38: What are the two steps a compiler performs? And what is the advantage of separating the two steps?


Q39: What is .o file? What is .a file in UNIX?


Q40: How do I control whether I run a process in the background when issued from a command window in UNIX? Do I have a similar control mechanism in Windows?


Q41: What is the name of the first PC-UNIX? Which company developed it and which company funded the development?


Q42: For what reasons early mainframes used magnetic tapes as main memory?


Q44: How does a cooperative multitasking OS switch from a process to another?


Q45: What is BIOS? Give me a short description.


Q46: What are the two steps a compiler performs? And what is the advantage of separating the two steps?


Q48: Which one below is a UNIX shell?
(a) Powersh
(b) Csh
(c) tcsh
(d) zshell
(e) besh


Q50: If progA is a program that prints on the screen, how do I make it print into a file called fileA instead?


Q51: If progB is a program that reads from the screen, how do I make it read from fileB instead?


Q52: Let's say I have thousands of files in a dir. I want to list them on the screen page by page. How?


Q53: What is the main difference between a process and a thread?


Q54: What is "dual mode"?


Q55: There are 3 processors connected in a pipeline that are cooperating to process incoming data and produce an output. Processor 1 (P1) takes 1 min to do its part and passes intermediate results to P2, P2 takes 3 min and passes results to P3, and P3 takes 5 min. What are the throughput and latency?


Q56: What is the difference between hup and nohup?


Q57: What is Protected Mode?


Q58: Same type of question as Q55 but assume 4 processors with 4, 5, 2, 2 minutes. What are the throughput and latency.


Q59: Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?


Q60: Writing an operating system that can operate without interference from malicious or undebugged user programs requires some hardware assistance. Name three hardware aids for writing an operating system, and describe how they could be used together to protect the operating system.


Q61: Some CPUs provide for more than two modes of operation. What are is a possible use of this?


Q62: What are the five major activities of an operating systemin regard to process management?


Q63: What are the three major activities of an operating system in regard to memory management?


Q64: What are the five major activities of an operating system in regard to file management?


Q65: What is the purpose of the command interpreter? Why is it usually separate from the kernel?


Q66: List five services provided by an operating system. Explain how each provides convenience to the users. Explain also in which cases it would be impossible for user-level programs to provide these services.


Q67: What is the purpose of system calls?


Q68: 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 swiching time. Assume we have only the following two processes running on the OS. P1 is started at t=0 and P2 at t=2ms. Below (P1: C3I5C4...) means P1 has a CPU curst of 3ms first then an I/O burst of 5ms, then a CPU burst of 4ms and so on. Give me the Gantt chart of how the OS schedules the two processes on the CPU and I/O as a tabel running vertically. Show the CPUwait and I/Owait queues.

  P1: C3I5C4I2C3
  P2: C6I3C2I6C5