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
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.