Home CS439

CS439: Principles of Computer Systems

Discussion Section Problem Set 1

Due in Section on Friday, September 5, 2025

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 differentiates a program, an executable, and a process?

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

  4. System Calls vs. Procedure Calls: How much more expensive is a system call than a procedure call? Write a simple test program to compare the cost of a simple procedure call to a simple system call ("getuid()" is a good candidate on UNIX; see the man page.) (Note: be careful to prevent the optimizing compiler from "optimizing out" your procedure calls. Do not compile with optimization on.)

    • Explain the difference (if any) between the time required by your simple procedure call and simple system call by discussing what work each call must do (be specific). [Note: Do not provide the source code for your program, just the results].

    Hint: You should use system calls such as gethrtime() or gettimeofday() for time measurements. Design your code such that the measurement overhead is negligible. Also, be aware that timer values in some systems have limited resolution (e.g., millisecond resolution).

  5. Your shell's PATH is a colon separated list of where to find programs to run. On Linux it can be printed out by running echo $PATH.

    Create a toy hello world program, and give it a name of an unimportant executable (like sl) then edit your PATH so that this program is run instead of its real equivalent. How did you change your PATH, and what does this say about the shell picks programs to run based on your PATH?

    Now remove execute permissions from your toy program using chmod -x {program_name}. What happens when you type your programs name into your shell?

    Hint: The following commands temporarily edit your PATH, try running them and note how your PATH changes.

    export PATH=$PATH:{new_directory}
    export PATH={new_directory}:$PATH

    Hint 2: sl does not allow keyboard interrupts by default. You might find it useful to read the man pages of sl using man sl.