1
h17
CS32 F20
Name:
(as it would appear on official course roster)
Umail address: @umail.ucsb.edu section
9am, 10am, 11am, 12pm
Optional: name you wish to be called
if different from name above.
Optional: name of "homework buddy"
(leaving this blank signifies "I worked alone"

h17: Processes

ready? assigned due points
true Tue 12/01 09:00AM Tue 12/08 11:59PM

You may collaborate on this homework with AT MOST one person, an optional "homework buddy".

MAY ONLY BE TURNED IN ON GRADESCOPE BEFORE THE DUE DATE,
There is NO MAKEUP for missed assignments;
in place of that, we drop the lowest scores (if you have zeros, those are the lowest scores.)


Reading: Processes, CS32 Reader (p. 117 - 146)

  1. (10 pts) Fill in the information in the header. The following are required to get the 10 "participation" points.
    • Filling in your name and umail address.
  2. (4 pts) Fill in the blanks, using the definition in the reading. Both are single words—the first starts with p, and the second starts with e.
     

    A process is a __________________________ in __________________________

  3. If you want to "suspend" a program that is running in a shell, in order to get to the shell prompt and do a few commands, then resume that program, what can you do?

    1. (4 pts) What do you type to suspend the current running program?
       
    2. (4 pts) What do you type to resume the suspended program?
       
  4. The command kill is used to, as the name would suggest, manually end processes. kill's primary function is to provide the user with control over processes that are running in the background and thus only accessible by a PID (process ID). kill features varying levels of ability to end process. Why is this fine-tuning useful? Answer the question by succinctly describing at least two different modes of kill and when each might be useful.

    1. (5 pts)
       
    2. (5 pts)
       
  5. Suppose you have a hello.cpp file that you've compiled into a binary called ./hello. As you know, you can run this with the steps shown below:
    -bash-4.2$ ./hello
    Hello, World
    -bash-4.2$
    

    In the steps shown, under the hood, somehow something called "fork and "exec" are involved in getting this program to actually start running. And there is some kind of "parent" and "child", somehow involved. For each of the following, describe its role, relating it to these concepts. Be brief but be just specific enough that the grader has NO DOUBT that you've read and understood the discussion of these concepts in the reading, and how each of them relates to running a ./hello program.

    1. (3 pts) fork
       
    2. (3 pts) exec
       
    3. (3 pts) parent
       
    4. (3 pts) child
       
  6. The ps command and the jobs command both list processes. Write a few words that distinguishes between the ways that they are used, that is:

    1. (3 pts) What is a circumstance where ps is more appropriate than jobs?
       
    2. (3 pts) What is a circumstance where jobs is more appropriate than ps?