[Return to Top] [Primary Objects]

EROS Object Reference

Primary Objects

Process

D R A F T

Description

A process defines the environment and access rights available to the program executing within that process. Among these, the process contains an address space containing the program code for that process. We say that the process obeys this program.

Processes can be in one of three states:
Available The process is available for entry by a thread via a start key. Equivalently, the process is available to provide services to its clients. Attempts to invoke a start key to a non-available process block until the process becomes available.
Running The process is currently occupied by a thread, which is executing instructions from the process's address space
Waiting The thread that last occupied this process performed a CALL operation, and the process is waiting for the resume key generated by that call to be invoked. A waiting process will be resumed at most once; the invocation of any copy of the resume key invalidates all other resume keys.

A process key conveys complete authority over the process, including the authority to alter its address space or registers, fabricate start keys, change the process's state. It is possible to perform operations using the process key that result in a malformed (and therefore unrunnable) process.

Typically, the process key conveys greater authority over the process than is enjoyed by the program that the process obeys.

Process key operations may be performed while the subject process is running. Such operations are atomic with respect to the subject process. The externally visible effect of such an operation will be as if the operation were performed between the completion of one instruction and the initiation of the next.

1 Process Layout

The layout of a process is architecture dependent, but many aspects of process layout are common across all 32-bit architectures. A minimal process consists of a single Node: the process root. The layout of this Node is as follows:

Process Root
Slot Usage Slot Usage
DR0 Schedule Class key DR16 Architecture Defined
DR1 Keeper key DR17 Architecture Defined
DR2 Address space key DR18 Architecture Defined
DR3 Key registers node key (if present). This slot will someday hold the capability space. DR19 Architecture Defined
DR4 I/O address space key. DR20 Architecture Defined
DR5 Reserved for Symbol table space key. DR21 Architecture Defined
DR6 Brand key DR22 Architecture Defined
DR7 Register slot
Bytes 0-3: Fault Code
Bytes 4-7: Fault Info
Byte 8: Run state (available, running, waiting)
Byte 8: Process flags byte.
DR23 Architecture Defined
DR8 Register slot
Bytes 0-3: PC
Bytes 4-7: SP
DR24 Architecture Defined
DR9 Architecture Defined DR25 Architecture Defined
DR10 Architecture Defined DR26 Architecture Defined
DR11 Architecture Defined DR27 Architecture Defined
DR12 Architecture Defined DR28 Architecture Defined
DR13 Architecture Defined DR29 Architecture Defined
DR14 Architecture Defined DR30 Architecture Defined
DR15 Architecture Defined DR31 Architecture Defined
1.1 Architecture-Defined Slots

Certain slots are architecture-defined, and are used to store architecture-specific register values. Spillover from the space available in the process root is usually handled by placing the remaining registers in the general registers Node. While this is the customary structure of a process, there are some exceptions:

x86 family All registers (both fixed and floating point) fit in the process root. Four pseudo-registers are defined by the architecture to carry invocation-related information.
32-bit SPARC family This machine has approximately 632 bytes of user-mode register state (I may have missed one or two), requiring a total of 53 number keys to hold user-mode register state. The process root has 23 architecture-defined registers, one of which is used to name an annex register node. If an additional node were required, a natural partitioning would be to isolate floating point state in its own node, since most processes do not use the floating point engine.
32-bit MIPS family All registers (both fixed and floating point) fit in the process root.
64-bit SPARC family In a full implementation, the 64-bit SPARC machine has 1216 bytes of user-mode register state, requiring a total of 102 number keys to contain them. Three annex nodes are required to hold this state. As with the 32-bit SPARC chip, the division of state does not admit of a convenient segregation of floating-point registers to reduce space.
1.2 Invocation Send and Receive Information

The EROS architecture defines a key invocation to pass four registers, four keys, and up to 64 Kbytes of data in each direction.

The registers passed by the invocation are architecture-specific. The passing of these registers is unconditional, because making it conditional is just as expensive as saving and restoring these registers.

The passing of keys is similarly unconditional, but the sender and receiver have control over which registers are passed and into which registers the incoming values are received. Because key register zero is ``hardwired'' to the void key, the transmitted capabilities can be directed to or from key register zero to achieve the effect of not sending any authority.

The message send and receive control blocks, then, must provide several pieces of information:

  • The type of the invocation.
  • A value describing which key register is to be invoked.
  • A value describing which four key registers are to be sent.
  • A value describing which four key registers are to receive the incoming keys.
  • A pointer to the data buffer to be sent.
  • The length of this send buffer.
  • A pointer to the location where incoming data should be received.
  • The length of this incoming buffer.

While the placement of these values in registers or memory is architecture specific, all 32-bit implementations share a common encoding of this information:

  • The send and receive pointers occupy a full 32-bit value each.

  • The send and receive length fields occupy a full 32-bit value each. On return, the receive length register contains the length of the string received, which is <= the receive length bound. A zero value in either length field indicates that no data is to be sent (received). In this event, the process may assume that the data pointer register(s) are not modified by the invocation.

  • The type of the invocation (reply = 0x0, call = 0x1, or send = 0x2) is encoded as a full 32-bit value. This may yet be merged into the receive keys word below.

  • The sent key register names are encoded into a single 32-bit word as follows:
     31  20 19  15 14  10 9    5 4    0
    +------+------+------+------+------+
    | zero | key3 | key2 | key1 | key0 |
    +------+------+------+------+------+
    	     
    Bits marked zero are reserved for future use.

  • The receive key register names and the invoked key are encoded into a single 32-bit word as follows:
    31  25 24     20 19  15 14  10 9    5 4    0
    +------+---------+------+------+------+------+
    | zero | inv key | key3 | key2 | key1 | key0 |
    +------+---------+------+------+------+------+
    	     
    Bits marked zero are reserved for future use.

    Encoding the invoked key along with the receive keys allows for a faster implementation on register-starved architectures.

1.4 Key Registers

Native EROS processes possess 32 key registers, which are contained in the key registers Node. Emulation processes are marked by a bit in the trap code key, and do not require a key registers Node (not yet implemented - for now, provide a key registers Node for all processes). The key register slots are referred to as KR0 through KR31.

In the following descriptions, certain operations are defined in terms of the slots of the process root Node


Operations

Check Alleged Key Type (OC = KT)

Returns the alleged type of the key.
Reply R1 AKT_Process: Key is a process key.

Copy Key (OC = 0)

Retrieves the key from slot N (0 <= N < 32) of the process root. The process root slot may not be the brand slot.
Request R1 The slot to be fetched.
Reply RK0 A copy of the requested key.
Result RC_OK Operation completed successfully.
RC_RequestError Invalid slot, or brand slot requested.
RC_Process_NoKeys Process has no key registers.
RC_Process_Malformed Process is malformed.

Swap Key (OC = 1)

Exchanges the key in slot N (0 <= N < 32) of the process root with the passed key. The returned key can be suppressed by specifying RK0 as the return key register. The process root slot may not be the brand slot.
Request R1 The slot N to be fetched.
SK0 The key to be placed in slot N.
Reply RK0 A copy of the key that previously occupied slot N.
Result RC_OK Operation completed successfully.
RC_RequestError Invalid slot, or brand slot requested.
RC_Process_NoKeys Process has no key registers.
RC_Process_Malformed Process is malformed.
RC_Process_Returnee Operation would modify the returnee. This usually means that the process key names the same process that is named by the resume key for this operation.

Copy Key Register (OC = 2)

Retrieves the key from key register N (0 <= N < 32) of the process.
Request R1 The slot to be fetched.
Reply RK0 A copy of the requested key.
Result RC_OK Operation completed successfully.
RC_RequestError Invalid slot number.
RC_Process_NoKeys Process has no key registers.
RC_Process_Malformed Process is malformed.

Swap Key Register (OC = 3)

Exchanges the key in capability register N (0 <= N < 32) of the process with the passed key. The returned key can be suppressed by specifying RK0 as the return key register.
Request R1 The capability register number N to be fetched.
SK0 The key to be placed in capability register N.
Reply RK0 A copy of the key that previously occupied capability register N.
Result RC_OK Operation completed successfully.
RC_RequestError Invalid slot, or brand slot requested.
RC_Process_NoKeys Process has no key registers.
RC_Process_Malformed Process is malformed.
RC_Process_Returnee Operation would modify the returnee. This usually means that the process key names the same process that is named by the resume key for this operation.

Get Registers (32 bit) (OC = 128)

Retrieves the complete set of register values from the process. The size and layout of the returned information is architecture specific, but the portion of the layout described below will be returned in the indicated locations by all architectures:
Reply W The processor architecture identifier, a byte-sex independent palindrome. Currently supported architectures and their associated architecture codes are:
Processor Code
386/486/Pentium 0x0b0000b0
W Size of reply message, in bytes.
W The current program counter.
W The current stack pointer.
W* Remaining registers
Result RC_OK Operation completed successfully.
2 The process was malformed. No action was taken.

Set Registers (32 bit) (OC = 144)

Sets the complete set of register values from the process. The size and layout of the message is architecture specific, but the portion of the layout described below will be in the indicated locations for all 32 bit architectures.

The provided message string must be the exact size of the register information structure for the architecture, as returned by Get Registers (32 bit).
Request W The architecture identifier, a byte-sex independent palindrome.
W Size of request buffer, in bytes.
W The current program counter.
W The current stack pointer.
W* Remaining registers
Result RC_OK Operation completed successfully.
2 The process was malformed. No action was taken.
RC_RequestError Insufficient length passed for message buffer, length field of message is wrong, or architecture field not for this architecture.
RC_Process_Returnee Operation would modify the returnee. This usually means that the process key names the same process that is named by the resume key for this operation.

Get Floating Point Registers (OC = 129)

Retrieves the floating point register set. The size and layout of the returned information is architecture specific, but the portion of the layout described below will be returned in the indicated locations by all architectures:
Reply W The floating point architecture identifier, a byte-sex independent palindrome. Currently supported architectures and their associated architecture codes are:
Processor Code
386/486/Pentium 0x0b0000b0
W Size of reply message, in bytes.
W* Remaining registers
Result RC_OK Operation completed successfully.
2 The process was malformed. No action was taken.

Set Floating Point Registers (OC = 145)

Sets the floating point register set values of the process. The size and layout of the message is architecture specific, but the portion of the layout described below will be in the indicated locations for all 32 bit architectures.

The provided message string must be the exact size of the register information structure for the architecture, as returned by Get Floatin Point Registers.
Request W The floating point architecture identifier, a byte-sex independent palindrome.
W Size of request message, in bytes.
W* Remaining registers
Result RC_OK Operation completed successfully.
2 The process was malformed. No action was taken.
RC_RequestError Insufficient length passed for message buffer, length field of message is wrong, or architecture field not for this architecture.
RC_Process_Returnee Operation would modify the returnee. This usually means that the process key names the same process that is named by the resume key for this operation.

Swap Memory (32-bit) (OC = 192)

Swaps the process's address space key (slot DR2) with the passed key and alters the value of the program counter in a single atomic operation.
Request W The new program counter value.
SK0 The key to be placed in slot DR2.
Reply RK0 A copy of the key that previously occupied DR2.
Result RC_OK Operation completed successfully.
RC_RequestError Wrong message string length.

Make Start Key (OC = 160)

Fabricates a start key to the process, using the low-order 16 bits of the passed word as the key data field of the new key. This order does not change the state of the process.
Request R1 The key data field value of the new start key.
Reply RK0 A start key to the process.
Result RC_OK Operation completed successfully.
RC_RequestError Wrong message string length

Make Resume Key (OC = 161)

Fabricates a resume key to the process, placing the process in the waiting state.
Reply RK0 A resume key to the process, or a void key.
Result RC_OK Operation completed successfully.
1 The process was running or waiting. No action was taken, and the returned key is a void key.
2 The process was malformed. No action was taken, and the returned key is a void key.

Make Fault Key (OC = 162)

Fabricates a fault key to the process, placing the process in the waiting state.
Reply RK0 A fault key to the process, or a void key.
Result RC_OK Operation completed successfully.
1 The process was running or waiting. No action was taken, and the returned key is a void key.
2 The process was malformed. No action was taken, and the returned key is a void key.

Make Process Available (OC = 176)

Changes the process to the available state, invalidating all outstanding resume keys to the process and destroying any thread that may currently occupy the process.
Result RC_OK The process was available already.
1 The process was running or waiting. It is now available.
2 The process was malformed. No action was performed.
RC_Process_Returnee Operation would modify the returnee. This usually means that the process key names the same process that is named by the resume key for this operation.

Make Process Waiting (OC = 177)

Changes the process to the waiting state, invalidating all outstanding resume keys to the process and destroying any thread that may currently occupy the process.
Reply RK0 A fault key to the process, or a void key.
Result RC_OK The process was available. The returned key is a fault key to the process.
1 The process was running or waiting. The returned key is a fault key to the process.
2 The process was malformed. No action was performed.
RC_Process_Returnee Operation would modify the returnee. This usually means that the process key names the same process that is named by the resume key for this operation.


Copyright 1998, 2001 by Jonathan Shapiro. All rights reserved. For terms of redistribution, see the GNU General Public License