Go to index, previous page, next page

SSI.cc

This module contains the code for the SSI (System Services Interface) thread of AMIKE OS.

It provides some low-level services to the other threads, like thread creation and termination, a timing service and so on.


This module exports:

typedef struct {
    int Service;
    int Payload;
} SSIMsg;
This datatype defines the structure of the messages the SSI can handle. The available services are described below, after the SSI function description.
void InitSSI( void ) explained below
void SSIrequest( int service, int payload, Message *reply ) explained below


Look at the header files: SSI.e, sysinterface.e


Module functions:

void InitSSI( void ) Sets up the SSI thread, allocating its stack and inserting it into the kernel ready queue. The SSI will run with interrupts disabled: this will give it an infinite time slice.
void SSIrequest( int service, int payload, Message *reply ) This is the interface function used by other threads to communicate with the SSI.

As MsgSend() and MsgRecv() need kernel mode to be invoked, SSIrequest() enters it. Please note that the calling thread requires at least CP0 access to invoke this function; if this isn't the case, the call will lead to a trap and thus to the termination of the thread.

void SSI( void ) This is the heart of the SSI thread. It consists of a MsgRecv() -> process request -> send answer loop.
If an unknown service is requested, the calling thread will be terminated.

After receiving a message, it will be dispatched to the right routine for the execution of the service. These routines will return a boolean value telling the SSI whether it has to send the answer to the calling thread right ahead or not. The latter means that the calling thread has been terminated or that it needs to stay in the wait queue (MsgSend() would awake the thread, which has been blocked by the MsgRecv() in SSIrequest()).

int CreateBrother( Message *msg ) Creates a thread whose initial state is the one passed as state_t * in the Payload field of the SSIMsg. The new thread will be inserted in the ready queue.
The function also take care of inheriting trap managers from the parent thread, if it exists.

The return value is a Thread * of the new thread, or CREATENOGOOD if the thread couldn't be created because of lack of resources.

int CreateSon( Message *msg ) This is almost the same of the previous service. The only difference is that the new thread will be inserted in the children list of the caller.

Note that children will be terminated when their parent is, and that brothers of a "son" will be considered as children of its parent thread.

int Terminate( Message *msg ) Kills the thread (and its descendants) specified in the payload field.
int SpecPrgMgr( Message *msg ) Specifies a PRGTRAP manager for the calling thread. Once the manager has been defined, an attempt to set a new one will cause the thread termination.
int SpecMemMgr( Message *msg ) As above, but related to TLBTRAP's.
int SpecSysMgr( Message *msg ) As above, but related to SYSTRAP's.
int GetCPUTime( Message *msg ) Returns the CPU time used by the calling thread so far.
int WaitForIO( Message *msg ) The calling thread wants to be blocked until the IO device with the specified Virtual Base Address raises an interrupt.

As the interrupt could preceed the call to WaitForIO() the function checks whether it has arrived; if not, it will set the WaitFor code of the thread to WF_IO, store the VBA among the thread data and leave it blocked; otherwise it will unblock it and set the MsgRecv() return code with the device status.

int WaitForClock( Message *msg ) The calling thread wants to be blocked until the pseudoclock will tick (it happens every 100ms), thus this function does nothing but set its WaitFor code to WF_CLOCK.
int PseudoClock( Message *msg ) This function will unblock all the threads waiting for the pseudo-clock tick.


Look at the code: SSI.cc


Go to index, previous page, next page