Houjun Liu

process control block

Each process is controlled by a struct which contain information about the process.

file descriptor table

Within each process, we have a file descriptor table (and the ints we get are indicies into this table), for which each entry stores points to the open file table.

When a process forks, the child doesn’t get more open file entries, instead, we simply clone the file descriptor table (i.e. parent and child will share the same underlying open file table entries); this is how we can share pipes.

This is why you need to CLOSE all open file descriptors once every PROCESS, including forked child.

thread state

Recall that threads are the unit of execution. The process control block keeps track of the *stack pointer* of the thread %rsp, which means if a thread is put to sleep the state can be stored somewhere on the stack.

  1. running
  2. blockde - waiting for an event like disk, network, etc.
  3. ready - able to run, but not on CPU yet

IO vs. CPU bound

  • I/O Bound Thread is a thread that needs to wait for disk events, and don’t need CPU that much
  • CPU Thread is a thread that needs CPU time