Simulator

This lesson explains how to run the simulator which mimics some aspects​ of an operating system to help you solidify your​ understanding.

We'll cover the following...

The program, process-run.py, allows you to see how process states change as programs run and either use the CPU (e.g., perform an add instruction) or do I/O (e.g., send a request to a disk and wait for it to complete).

As described in the chapter, processes can be in a few different states:

  • RUNNING - the process is using the CPU right now

  • READY - the process could be using the CPU right now but (alas) some other process is

  • WAITING - the process is waiting on I/O (e.g., it issued a request to a disk)

  • DONE - the process is finished executing

To run the program and get its options, do this in the terminal provided below:

prompt> ./process-run.py -h

If this doesn’t work, type “python” before the command, like this:

prompt> python process-run.py -h
Terminal 1
Terminal
Loading...

What you should see is this:

Usage: process-run.py [options

Options:
  -h, --help            show this help message and exit
  -s SEED, --seed=SEED  the random seed
  -l PROCESS_LIST, --processlist=PROCESS_LIST
                        a comma-separated list of processes to run, in the
                        form X1:Y1,X2:Y2,... where X is the number of
                        instructions that process should run, and Y the
                        chances (from 0 to 100)
...
Access this course and 1400+ top-rated courses and projects.