Go up to Process Management
Go forward to The createproc Primitive

Process Control Block Structure

All of the process management functions of your kernel will revolve around the data structure that represents a process in your system -- its process control block (PCB). A structure declaration for the type I would like you to use to represent PCB's is shown below.(1)
struct pcb    /* structure used to describe a process */
  char *name;       /* The process' name (significant only for debugging)  */
  int priority;     /* The process' scheduling priority                    */
  int *SPvalue;     /* The process' stack pointer register value (i.e. A7) */
  int PSvalue;      /* The process' program status register value (i.e.    */
                    /*   its interrupt priority).                          */

  int *FPvalue;	    /* The process' frame pointer register value (i.e. A6) */  
  struct pcb 
    *thread;        /* Link field used when process is added to any list   */
                    /*   (such as the ready list or list waiting on a      */
                    /*    mailbox).                                        */
;
The functions of each of the components is explained below.

The "name" field should be set to point to the string which names the process. This field will not be used by the system, but will probably be very helpful when debugging since it provides a quick way to determine which process is running.

When selecting a process to run, your kernel will examine all ready processes and select one based on its "priority". A process with a high priority value will always be selected over a process with a lower priority. A process' priority will be initialized as part of the createproc procedure described below. Since we are not concerned with security in this system, any process is free to change the "priority" field of its PCB later.

Note that this "priority" field is different from the processor priority stored in the processor status register. The PCB "priority" component determines which process the kernel's scheduler will pick to run next. The other value (stored in the PS register or the PCB's PSvalue field) determines whether or not the CPU will recognize an interrupt request now or later.

Three components of a process' volatile state will need to be stored in the PCB while the process is suspended. These are the stack pointer register's value (A7), the frame pointer register's value (A6) and the contents of the processor status register (PS). The fields named "SPvalue", "PSvalue" and "FPvalue" will be used to hold this state information. Other register values that need to be saved can be store on the stack pointed to by "SPvalue".

As explained in class, a kernel needs to keep track of which processes are ready and which are waiting for various classes of events. The easiest way to do this is to keep lists of each type of process. In your system, there will be a list of ready processes and a list of processes waiting on each mailbox. Each process will be on at most one list at any time. Accordingly, we provide just one field named "thread" in the PCB to hold the "next" pointer for whatever linked list currently holds the process.



Up Next