next up previous contents
Next: 12.4 IPC System Calls Up: (X86) Processor-specific Fluke Interface Previous: 12.2 System Calls

12.3 Thread System Calls

The x86 specific state of a thread is defined in <fluke/x86/thread.h>:

struct fluke_thread_state
{
        unsigned        eax;
        unsigned        ebx;
        unsigned        ecx;
        unsigned        edx;
        unsigned        esi;
        unsigned        edi;
        unsigned        ebp;
        unsigned        esp;
        unsigned        eip;
        unsigned        eflags;
        unsigned        min_msg[2];

        unsigned        trap_handler;
        unsigned        interrupt_handler;
        unsigned        client_alert_handler;
        unsigned        server_alert_handler;
        unsigned        saved_eax;
        unsigned        saved_ecx;
        unsigned        saved_edx;
        unsigned        saved_eip;
        unsigned        saved_eflags;

        fluke_pset_t    *server_pset;
        unsigned        server_esp;
        unsigned        server_oneway_eip;
        unsigned        server_idempotent_eip;
        unsigned        server_reliable_eip;
};

The first section contains the processor registers. The min_msg words are ``extra'' registers which are used to save the minimum message words passed to the receiver during IPC operations. This is a kludge resulting from the x86's scarcity of registers.

Next come a set of exception handlers for each of the main types of thread exceptions. Each contains a pointer to a routine that is invoked when that exception occurs and THREAD_EXCEPTION_ENABLE is set in the thread flags. Hence, these only need to be valid if THREAD_EXCEPTION_ENABLE flag is set. Following the handlers is a set of save locations for thread exceptions. When an exception is dispatched to the thread, the original values of eax, ecx, edx, and eip are saved here, and the registers are set as follows:

eax
A pointer to the current thread, so the exception handler has ``a place to stand.''
ecx
The exception ``code.''
edx
The exception ``subcode.''
eip
The exception handler entrypoint (one of the _handler values above).
eflags
Original eflags with TF bit clear.

The final set of fields are only relevant for threads acting as servers.

The minimum x86-specific state required (via fluke_thread_set_state) to get a Fluke thread running is legitimate values for eip and esp. However, it is recommended that all other fields be zeroed to avoid unexpected thread behaviors.



Utah Flux Research Group