Mechanism for obtaining a thread from, and returning a thread to, a thread pool without attaching and detaching
First Claim
1. A computer implemented method for servicing a request, comprising:
- receiving a request for a service which requires invocation of one or more resources provided by an engine;
assigning a thread from a thread pool for use in servicing said request;
determining whether said thread is already attached to said engine, wherein said thread is attached to said engine if said thread is enabled to invoke the one or more resources provided by said engine; and
in response to a determination that said thread is already attached to said engine, servicing said request using said thread without first attaching said thread to said engine.
3 Assignments
0 Petitions
Accused Products
Abstract
A JAVA application is typically executed as follows. First, a thread from a thread pool is attached to the JAVA virtual machine (JVM). Then, that thread is used to execute the JAVA application. Once the execution of the JAVA application is completed, the thread is detached from the JVM and returned to the thread pool. This is repeated for every execution of a JAVA application. Because this constant attaching and detaching of threads imposes additional overhead on the system, this process is inefficient. To improve the efficiency of the execution process, a “sticky attach” mechanism is provided. With sticky attach, a thread is not attached and detached from the JVM each time a JAVA application is executed. Rather, a thread is attached to the JVM only once: the first time it is used to execute a JAVA application. When execution of the JAVA application is completed, the thread is returned to the thread pool without detaching from the JVM. That way, the next time that thread is obtained from the thread pool, there will be no need to reattach it to the JVM. It will already be attached. Thus, it can be used as is to execute a JAVA application. By eliminating the need to constantly attach and detach threads, the sticky attach mechanism significantly decreases overhead. This in turn increases overall system efficiency.
107 Citations
30 Claims
-
1. A computer implemented method for servicing a request, comprising:
-
receiving a request for a service which requires invocation of one or more resources provided by an engine;
assigning a thread from a thread pool for use in servicing said request;
determining whether said thread is already attached to said engine, wherein said thread is attached to said engine if said thread is enabled to invoke the one or more resources provided by said engine; and
in response to a determination that said thread is already attached to said engine, servicing said request using said thread without first attaching said thread to said engine. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
upon completion of servicing of said request, returning said thread to said thread pool without detaching said thread from said engine.
-
-
3. The method of claim 2, wherein said thread has private storage associated therewith, and wherein determining comprises:
determining whether the private storage associated with said thread comprises an environment structure which enables said thread to invoke the one or more resources provided by said engine.
-
4. The method of claim 3, wherein said environment structure comprises:
-
one or more references to the one or more resources provided by said engine; and
storage for storing local references to data structures pertaining to said engine.
-
-
5. The method of claim 2, wherein said thread pool is dedicated to servicing requests requiring invocation of said engine.
-
6. The method of claim 2, wherein said engine is a JAVA virtual machine (JVM).
-
7. The method of claim 2, further comprising:
-
in response to a determination that said thread is not already attached to said engine, attaching said thread to said engine; and
servicing said request using said thread.
-
-
8. The method of claim 7, wherein attaching comprises:
registering said thread with said engine.
-
9. The method of claim 8, wherein said thread has private storage associated therewith, and wherein attaching further comprises:
allocating an environment structure within the private storage associated with said thread, said environment structure enabling said thread to invoke the one or more resources provided by said engine.
-
10. The method of claim 9, wherein said environment structure comprises:
-
one or more references to the one or more resources provided by said engine; and
storage for storing local references to data structures pertaining to said engine.
-
-
11. An apparatus for servicing a request, comprising:
-
a mechanism for receiving a request for a service which requires invocation of one or more resources provided by an engine;
a mechanism for assigning a thread from a thread pool for use in servicing said request;
a mechanism for determining whether said thread is already attached to said engine, wherein said thread is attached to said engine if said thread is enabled to invoke the one or more resources provided by said engine; and
a mechanism for servicing, in response to a determination that said thread is already attached to said engine, said request using said thread without first attaching said thread to said engine. - View Dependent Claims (12, 13, 14, 15, 16, 17, 18, 19, 20)
a mechanism for returning, upon completion of servicing of said request, said thread to said thread pool without detaching said thread from said engine.
-
-
13. The apparatus of claim 12, wherein said thread has private storage associated therewith, and wherein the mechanism for determining comprises:
a mechanism for determining whether the private storage associated with said thread comprises an environment structure which enables said thread to invoke the one or more resources provided by said engine.
-
14. The apparatus of claim 13, wherein said environment structure comprises:
-
one or more references to the one or more resources provided by said engine; and
storage for storing local references to data structures pertaining to said engine.
-
-
15. The apparatus of claim 12, wherein said thread pool is dedicated to servicing requests requiring invocation of said engine.
-
16. The apparatus of claim 12, wherein said engine is a JAVA virtual machine (JVM).
-
17. The apparatus of claim 12, further comprising:
-
a mechanism for attaching, in response to a determination that said thread is not already attached to said engine, said thread to said engine; and
a mechanism for servicing said request using said thread.
-
-
18. The apparatus of claim 17, wherein the mechanism for attaching comprises:
a mechanism for registering said thread with said engine.
-
19. The apparatus of claim 18, wherein said thread has private storage associated therewith, and wherein the mechanism for attaching further comprises:
a mechanism for allocating an environment structure within the private storage associated with said thread, said environment structure enabling said thread to invoke the one or more resources provided by said engine.
-
20. The apparatus of claim 19, wherein said environment structure comprises:
-
one or more references to the one or more resources provided by said engine; and
storage for storing local references to data structures pertaining to said engine.
-
-
21. A computer readable medium having stored thereon instructions which, when executed by one or more processors, cause the one or more processors to service a request, said computer readable medium comprising:
-
instructions for causing one or more processors to receive a request for a service which requires invocation of one or more resources provided by an engine;
instructions for causing one or more processors to assign a thread from a thread pool for use in servicing said request;
instructions for causing one or more processors to determine whether said thread is already attached to said engine, wherein said thread is attached to said engine if said thread is enabled to invoke the one or more resources provided by said engine; and
instructions for causing one or more processors to service, in response to a determination that said thread is already attached to said engine, said request using said thread without first attaching said thread to said engine. - View Dependent Claims (22, 23, 24, 25, 26, 27, 28, 29, 30)
instructions for causing one or more processors to return, upon completion of servicing of said request, said thread to said thread pool without detaching said thread from said engine.
-
-
23. The computer readable medium of claim 22, wherein said thread has private storage associated therewith, and wherein the instructions for causing one or more processors to determine comprises:
instructions for causing one or more processors to determine whether the private storage associated with said thread comprises an environment structure which enables said thread to invoke the one or more resources provided by said engine.
-
24. The computer readable medium of claim 23, wherein said environment structure comprises:
-
one or more references to the one or more resources provided by said engine; and
storage for storing local references to data structures pertaining to said engine.
-
-
25. The computer readable medium of claim 22, wherein said thread pool is dedicated to servicing requests requiring invocation of said engine.
-
26. The computer readable medium of claim 22, wherein said engine is a JAVA virtual machine (JVM).
-
27. The computer readable medium of claim 22, further comprising:
-
instructions for causing one or more processors to attach, in response to a determination that said thread is not already attached to said engine, said thread to said engine; and
instructions for causing one or more processors to service said request using said thread.
-
-
28. The computer readable medium of claim 27, wherein the instructions for causing one or more processors to attach comprises:
instructions for causing one or more processors to register said thread with said engine.
-
29. The computer readable medium of claim 28, wherein said thread has private storage associated therewith, and wherein the instructions for causing one or more processors to attach further comprises:
instructions for causing one or more processors to allocate an environment structure within the private storage associated with said thread, said environment structure enabling said thread to invoke the one or more resources provided by said engine.
-
30. The computer readable medium of claim 29, wherein said environment structure comprises:
-
one or more references to the one or more resources provided by said engine; and
storage for storing local references to data structures pertaining to said engine.
-
Specification