[Brandon University crest][The famous "Halfway Tree" of the Prairies, between Winnipeg and Brandon]


KModel
 


Site Map

  Kmodel Home  
  - Download
  - Installation
  - Javadoc

  Hardware Model
  - Serial  
  - Timer  
  - Disk  

  Kernel Design  
  - Modules  
  - User Process  
  - Kernel Entry  
  - Kernel Call  
  - Handles  
  - Signals

  Components  
  - Processes  
  - Console  
  - Timer  
  - Disk  

  File System  
  - Disk Layout
  - Buffer Cache
  - Inode Cache
  - Standard Files
  - Vnodes

  Study Questions  

 

   

User Processes

User processes are implemented by Java threads.  Each user process is represented by the class Application in Figure 1. Part of the class structure in the diagram is considered as "kernel space". The classes labeled Process, Application and SysLib are "user space", although Process is defined in the kernel package.

Figure: User Processes

Although a user process runs in a thread, it is not derived from Thread but contained, rather, as a field in ProcessWrapper, which is derived from Thread. The reason for this separation is to hide the PCB from the process. The PCB is required by startup code in ProcessWrapper to establish the constraint that only one process is active at a time. That is, the startup code in ProcessWrapper executes, as it were, on the kernel side.

In the code below, the run() method of ProcessWrapper begins by blocking on its own PCB. 

class ProcessWrapper extends Thread {
    PCB pcb;
    Process userprocess;
    
    ProcessWrapper(PCB pcb, Process process) {
        this.pcb = pcb;
        this.userprocess = process;
    }
    
    final public void run() {
        pcb.block();
        try {
            userprocess.main();
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
        userprocess.SVC(3);
    }
}

A user process is any class derived from kernel.Process. For example, here is the code for HelloWorld.

package user;

public class HelloWorld extends kernel.Process {
    SysLib lib = new SysLib(this);
    public HelloWorld() {
    }
    public void main(String [] args) {
        lib.puts("Hello, World\r\n");
    }
    
}

User processes must have access to the interrupt mechanism in order to make system calls. This is done by calling one of the convenience methods SVC, visible through inheritance. Each SVC method prepares parameters in the kparam array of Process, invokes the interrupter and returns the result of the system call.

SysLib puts wrappers around system calls to strongly type the arguments and result. This is explained in the section Kernel Calls.

 


Last update 01/24/05
Copyright © Gerald Dueck
[=]