Process 1: Basics

Overview

In this lecture, we discuss processor cache performance and transition to the process control unit.

Full lecture notes on process controlTextbook readings

Processor cache

Machine learning Matrix multiplication

Matrix multiplication definition

Matrix multiplication dimensions

Matrix multiplication cell computation

Implementing matrix multiplication

    // clear `c`
    for (size_t i = 0; i != c.size(); ++i) {
        for (size_t j = 0; j != c.size(); ++j) {
            c.at(i, j) = 0;
        }
    }

    // compute product and update `c`
    for (size_t i = 0; i != c.size(); ++i) {
        for (size_t j = 0; j != c.size(); ++j) {
            for (size_t k = 0; k != c.size(); ++k) {
                c.at(i, j) += a.at(i, k) * b.at(k, j);
            }
        }
    }

Question

Processes

Process coordination

Basic shell operation

  1. Print a prompt
  2. Wait for user to enter a command line
  3. Execute the command line in a new process or processes
  4. Wait for the command line processes to complete
  5. Repeat

Simple shell commands

$ echo foo
foo
$ sleep 5

Process control system calls

Process = image + identity + environment view

fork creates a new process

fork, stdio, and coherence

Process hierarchy

fork: Which runs first?

The uniq utility

execvp runs a new program

_exit terminates this process

waitpid monitors a child process for completion

minishell.cc

Question

pid_t p1 = getpid();
pid_t p2 = getppid();
pid_t p3 = fork();
pid_t p4 = getpid();
pid_t p5 = getppid();
assert(???);

Some answers

Exit notification as a communication channel