Home CS439

CS439: Principles of Computer Systems

Discussion Section Problem Set 1

Due in Section on Friday, September 7, 2018

The problem set must be completed before section and brought to section. To ensure that your problem set is turned in correctly and that you receive credit for discussion section, you must follow these guidelines exactly.

  1. Name and briefly describe three OS interfaces.

  2. What are the three methods of switching from user mode to supervisor mode? When might each occur?

  3. Write a C program that expects an integer command line argument, x, and then uses recursion to print, Hello, World! x times. Paste the code into your homework.
  4. [The next three questions relate to the program you just wrote.]

  5. Compile your program from the previous problem on the CS Linux machines using gcc. Use command line options to:
    1. Name the executable file hello.
    2. Set the optimization to level 0.
    3. Turn on the debugging information.

    You may find the overview of gcc on the course homepage helpful.

    What command did you use?

  6. Run your program from within gdb with an argument of 5.
    1. Set a break point at the entrance to your recursive function.
    2. Print the value of the argument to the function.
    3. Step through each line of the function until Hello, World! is printed.
    4. Continue the execution until the next breakpoint is reached. Check the value of the argument, and, if it is not the last recursive call, continue the program.
    5. On the last recursive call, print a backtrace of the call stack. Identify the line number of the call to your recursive function in main().

    What commands did you use in gdb? What is the line number of your recursive call?

  7. Return to your program and add an if statement in main after the recursive call that reads:
    if(x == x)
    where x is the name of the argument to the recursive call. (If you didn't save it into a variable before, please do so now!)

    Recompile your program with the optimizations set to level 4.

    Run your program using gdb, but set a breakpoint in main for the if statement and inspect the value of x. What do you learn?

  8. Create a name tent for use during all discussion sections this semester. Your name tent must be typed and your first name (or the name you would like to be called) must be displayed in a font size of at least 78pt. Your last name should be on the next line and must be displayed in a font size of at least 48pt. If you are unsure of either what a name tent is or how to create one, many examples can be found using Google (probably the one and only time this semester we will recommend Google). Bring your name tent with you to discussion section (there is no need to turn it in to Canvas).
  9. While holding your name tent, capture a picture of yourself, name it lastname_firstname.extension and upload it to the Section 1 assignment in Canvas. The picture must be appropriate, taken in protrait mode, and we must be able to read the name tent and see your face, but the rest is up to you.