Inheritable thread-local storage

Electrical computers and digital processing systems: virtual mac – Task management or control

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

C717S114000, C717S116000

Reexamination Certificate

active

06820261

ABSTRACT:

BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates generally to the field of computer software, and more particularly to inheritable thread-local storage.
2. Description of the Related Art
Modern multitasking operating systems support multiple threads, which allow many activities to execute simultaneously. For example, searches on multiple remote databases may all be launched by one task, each search corresponding to a unique thread, and executed simultaneously. Oftentimes, it is convenient to have storage that is unique to each thread. Unfortunately, most programming languages do not support such storage. However, there is a standard software mechanism for threads to associate implicit scope information with themselves, known variously as “thread-local data” or “thread-specific data.” This facility exists in many threading facilities, including POSIX Threads (“Pthreads”) and Win32 Threads.
Under POSIX, thread-specific data allows each thread to have a separate copy of a variable, which is indexed by a common “key” value. A key is created and each thread independently sets or gets its own unique value for that key. The key is the same for all the threads, but each thread can associate its own unique value with the shared key. Each thread can change its private value for a key without affecting the key or any other thread's value for the key. When the threading system is asked for a new key, a new variable is created. This type of “key” system is not secure, however, since the keys can be forged and data accessed without permission. The POSIX thread-specific data mechanism is explained in further detail in
Programming in POSIX Threads
, David R. Butenhof, Addison-Wesley, 1997, herein incorporated by reference. A similar mechanism is available in the Windows 95 operating system, and is discussed in
Programming Windows
95, Charles Petzold, Microsoft Press, 1996, herein incorporated by reference.
The Java™ programming language, created by Sun Microsystems, is somewhat unique among programming languages in that it has built-in thread-local storage support. Specifically, there is a public class “ThreadLocal” that provides thread-local variables. The thread-local variables differ from the other “normal” Java variables in that each thread that accesses a thread-local variable (via a get or set method) has its own, independently initialized copy of the variable. ThreadLocal objects are typically private static variables in classes that want to associate a state with a thread, such as a user ID or a transaction ID. Each thread holds an implicit reference to its copy of a ThreadLocal as long as the thread is in existence and is accessible. After a thread terminates, all of its copies of ThreadLocal variables are subject to garbage collection, unless other references to these copies exist.
FIG. 3
is a table illustrating the API specification for the class ThreadLocal.
For many programming applications, is often desirable for threads to carry with them some implicit “scope” information, such as the principal or transaction on whose behalf the thread is executing. When a thread (“the parent”) creates another thread (“the child”), it is often desirable that this scope information be automatically transmitted from parent to child, in a manner that may depend on the details of the scope information in question. The thread-specific data (hereinafter “thread-local data” or “thread-local storage”) mechanisms described above do not solve this problem, however, since values are not passed from parent threads to child threads.
In view of the foregoing, it would be desirable to have a thread-local storage mechanism in which a child thread can inherit its parent's values directly, or in which a child thread could inherit values which are some functions of the parent's values.
SUMMARY OF THE INVENTION
In a threading mechanism, the present invention is a system and method for providing automatic value inheritance when a parent thread creates a child thread. Upon the creation of a child thread, the system iterates over all of the inheritable thread-local values associated with the parent thread and initializes the child's values of these inheritable thread-local values, based on an appropriate childValue method.
In a first embodiment, for each thread, a hash table maps each thread local object to a value. In a preferred implementation, the hash table is two separate logical maps—one for inheritable values and one for non-inheritable values. When a thread creates a child, the system iterates over the inheritable value map to create the child's values. An inheritance protocol (i.e. the “childValue” method) may be performed on the values in order to calculate the child's value as a function of the parent's value, if desired.
In an alternative embodiment, the two hash tables in the first embodiment can be combined into one table, with each entry having a flag to identify the inheritable values.
In a second embodiment of the present invention, for each thread-local variable, a hash table maps each thread to a value. An object reference to a current thread is used as a look-up key in the hash table to find the value associated with this thread. For each thread, a linked list called “values” links all the inheritable thread-local values associated with the thread. The head pointer to the linked list of inheritable values is stored in the thread object. When a parent thread creates a child thread, the system iterates over the linked list of thread-local values pertaining to the parent thread. For each parent value, a “childValue” method is invoked to initialize the associated child's value.
In a preferred embodiment, the present invention is implemented in the Java™ programming language. The InheritableThreadLocal class of the present invention extends the ThreadLocal class to provide inheritance of values from a parent thread to a child thread. When a child thread is created, the child receives initial values for all InheritableThreadLocals for which the parent has values. Normally, the child's values will be identical to the parent's values. However, the child's value can be made to be an arbitrary function of the parent's value by overriding the “childValue” method in the InheritableThreadLocal class.


REFERENCES:
patent: 5893912 (1999-04-01), Freund et al.
patent: 5913059 (1999-06-01), Torii
patent: 6026428 (2000-02-01), Hutchison et al.
patent: 6272518 (2001-08-01), Blazo et al.
patent: 6286027 (2001-09-01), Dwyer et al.
patent: 6292820 (2001-09-01), Korn
patent: 6370684 (2002-04-01), De Pauw et al.
patent: 6378004 (2002-04-01), Galloway et al.
patent: 6418442 (2002-07-01), Dwyer III
patent: 6553531 (2003-04-01), Kim et al.
patent: 6560628 (2003-05-01), Murata
patent: 6643802 (2003-11-01), Frost et al.
Butenhof, “Thread Specific Data”, Programming with Posix® Threads, Chapter 5, pp 161-172.
Petzold, “Thread Local Storage (TLS)”, Programming Windows® 95, Section IV The Kernel and the Printer, pp 780-781.

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Inheritable thread-local storage does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Inheritable thread-local storage, we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Inheritable thread-local storage will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-3350893

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.