Evaluator Manager

The internals of the S code map the S level threads to the corresponding internal structures (Pthread objects or Solaris threads or however they are implemented) when created. These S engine maps many of the user level thread functions (such as yield, cancel, getLock, etc.) to their corresponding native functions in the base language and in doing so, has the possibility of maintaining the status of the different objects (threads, locks, etc.). Also, providing an interface to many of these functions allows the engine to govern the behavior of the threads and locks, restrict certain actions. We call the part of the S engine that performs the necessary bookkeeping and and query responses the Evaluator Manager. The Manager provides many of the services necessary for monitoring and debugging threads and also can prohibit erroneous deadlock, priority inversion, etc. The Manager has the potential to solve many of the difficulties associated with a threaded environment and also to reduce the performance of all the threads significantly. Care is taken in implementing the selected features for this component of the S engine.

The Evaluator Manager shares some of the features of a kernel that manages the process for an operating system. It provides encapsulated access to several of the internal aspects of user threads such as

This reduces the number of routines in the code that need to know about the details of the implementation. In the pursuit of porting user threads to different types of native threads (user libraries and kernel threads) on several operating systems (UNIX and Win95, NT), this is essential. A thread that wants to operate on another thread sends the request to the manager which validates the request (by checking that the requesting thread is allowed to perform this action, etc.) and notifies the calling thread of the completion of the request, if necessary. In this way, the manager behaves as a central server for all the threads and makes it easier to integrate new or different features.

When a thread terminates, it can return a value (including its toplevel database/session frame) which can be recovered by other threads that join() on it . The Manager provides a central location in which the return value from each thread is cached for use in other threads.

When the user wants to perform a task in a thread, the Manager can choose to not create a new thread but to employ an existing thread that is idle. This can be more efficient and allows a simple and local form of thread pools.

The manager can also arrange to trace the acquisition and release of the lock of a threadLock object. This allows the manager to know which thread holds each lock an can be requested to determine if deadlock exists for a group of threads. The Manager also handles the waiting of the different threads on a condition of a a variable in different threadLock objects. This allows the manager to report information about the state of different threads and also report on and/or avoid potential syncrhonization deadlock. This is a potentially useful facility for debugging complicated syncrhonization situations.

S is a statistical analysis application, so it is appropriate that statistics relating to itself be available to the user. The manager records information about the time a thread was created. The manager can arrange to be notified each time a different thread becomes the active thread and so can keep detailed records of the CPU time used within this process of each thread. Additionally, the Manager can be requested to keep statistics about certain objects used in specific threads involved in threading so as to be able to get runtime statistics on particular synchronization sections and strategies.

In a future implementation of the user level threads, the manager will manage the scheduling the different user threads in a fully portable manner. It might provide hooks to override the thread libraries scheduling algorithm and make this available to the S programmer for developers to experiment with different scheduling mechanisms.

One of the r\^oles of the Evaluator Manager is to store thread specific information. As more threads are created, the list of thread information objects could grow and consume a sizeable section of the processes memory resources. Accordingly, the evaluator manager attempts to perform a simple form of garbage collection to release the unnecessary objects. The manager decides what thread information objects are unecessary as follows. If a particular thread is created with the value T for the detach attribute, the return value is ignored by the evaluator manager and discarded. When the thread terminates, all related information is discarded. Alternatively, for a non-detached thread, the access attribute governs the lifespan of the threads return value. If the access is a list of threads and threadGroups, the Evaluator Manager caches the thread information, including the return value, until all threads in this list are themselves terminated. In the absence of preprocessing/compiling the thread tasks, the thread information cannot be released earlier without removing the ability of any of the threads in the access list to query the information about this thread. Threads not in the access list cannot join() on this thread and so the return value and thread information are redundant.

If the access attribute has the value T, implying that all threads, that exist now and in the future, have access to this thread, the return value is never released by the #Evaluator Manager">Evaluator Manager. This is another reason for seriously considering the access attribute of a thread.


Last modified: Mon Feb 10 16:32:38 1997