Home CS439

CS439: Principles of Computer Systems

Homework 2, Part 1

Due: 8:45a Friday, February 6, 2015

Part 1 of the homeworks must be submitted electronically. Please refer to the homework turnin instructions.

  1. Open a terminal on a departmental Linux machine. After ensuring that you are in a bash shell, use the time command to measure the time taken by a Linux command that sends output to the screen (and maybe other things as well). You may use any Linux command you like. For instance, a sample run might be (from your Project 0 directory):

    time make

    Inspect the output. Explain the meaning of each line. Is the output as you would expect? Why or why not? Include your command in your answer.

  2. A typical hardware architecture provides an instruction called return from interrupt, which is abbreviated by something like rti. This instruction, which is usually only available while the machine is running in kernel mode, switches the mode of operation from kernel mode to user mode.

    • Explain under what circumstances this instruction would be used by the operating system.

    • What happens if an application program executes this instruction?

  3. What differentiates a program, an executable, and a process?

  4. Given the following piece of code:
       main(int argc, char** argv)
       {
          forkThem(5);
       }
    
       void forkThem(int n)
       {
          if(n>0)
          {
             fork();
             forkThem(n-1);
          }
       }
    

    How many processes are created if the above piece of code is run?

  5. Compare and contrast user threads and kernel threads.