Patent ID: 7398521

Claim:
A method, comprising: creating, automatically during a compilation of code, a plurality of threads executable in a processor of a data processing system, resulting in a thread tree potentially for at least one function in the code, wherein the thread tree represents a thread dependency graph of the plurality of threads; selecting a current thread by traversing the thread tree in a bottom-up order that ensures that all child threads of the current thread had been selected before selecting the current thread as a parent thread; determining resources allocated to one or more child threads spawned from the current thread; and allocating resources for the current thread in consideration of the resources allocated to the current thread's one or more child threads to avoid resource conflicts between the current thread and its one or more child threads, wherein the allocated resources include one or move hardware registers and physical memory associated with the processor used by each of the plurality of threads, and wherein the resources allocated to the one or more child threads are recorded in a data structure maintained by a compiler of the Compilation to enable the compiler a avoid the resource conflicts between the current thread and the one or more child threads such that the processor performs less resource management actions during executing the plurality of the threads by the processor.