CMPSCI 377: Operating Systems
Discussion 2: OS Design and System Calls


Reminders:

  1. TA office hours on 9/14 are moved to 9:30-11 AM.
  2. Please submit your course collaboration document on Moodle if you have not done so already.
  3. Instructions on setting up Nachos will be posted shortly (we will notify you).

Links:

  1. Slides from discussion: slides.pdf
  2. Discussion questions and solutions
  3. Code to the C fork program we walked through: fork1.c. Compile with
    gcc -o fork1 fork1.c
    and then run the resulting binary with
    ./fork1
  4. Code to the Java exec program we discussed in the context of fork: ExecTest.java. Recall that we discussed how you can use use the fork call (which creates a new process) and the exec call (which transforms the current process into a different program, like hostname in the previous example) to implement the command execution framework of Runtime.exec() in Java.

    In fact, using a combination of fork and exec is how most command line shells (e.g., Bash) are implemented. See this page for a good reference on Unix system calls - in particular, I'd recommend reading the (very brief) section on fork and wait. Just following those sections is an example of implementing a simple shell program using fork, exec, and wait.