A computing device, such as a server, router, desktop computer, laptop, etc., and other devices having processor logic and memory, includes an operating system layer and an application layer to enable the device to perform various functions or roles. The operating system layer includes a master control program that runs the computing device. The master control program provides task management, device management, and data management, among others. The operating system layer contains an operating system that sets the standards for application programs that run on the computing device. Before a computing device may accomplish a desired task, it must receive an appropriate set of instructions. Executed by a device's processor(s), these instructions direct the operation of the device. These instructions can be stored in a memory of the computer. Instructions can invoke other instructions. Application layers are considered to be logic layers which are located above the operating system layer. As used herein, “user” space, or “user-mode” implies a layer of code which is more easily accessible, e.g., includes open-source code, than the layer of code which is in the operating system layer or “kernel” space.
In an operating system, a process refers to a running program with input, output, and a state. Each process has one or more threads. A thread is an executable set of instructions being executed by a single processor. A thread is sometimes referred to as a lightweight process. For example, a process contains attributes shared by all executing threads in the in the process, such as an address space, file descriptors, and variables of an executing instance of a program. Processes and threads are well known in the art and are described, for example, in Modern Operating Systems, Andrew S. Tannenbaum, (1992).
A process may start one or many other processes. A process which starts another is referred to as a parent process and the process which was started thereby is referred to as the child process. In operating system semantics parent processes are responsible for “waiting on” (e.g., cleaning up) their child(ren) process(es) when the child(ren) process(es) are completed. When a parent process exits or ends before the child(ren) process(es), the responsibility for the child(ren) process(es) (e.g., orphaned processes) are turned over to (e.g., adopted by) a system process. This is just one of example of how processes are “orphaned” to the system. The system process has restrictions placed on its scheduling priorities. That is, the system process has its own set of responsibilities including starting and restarting other processes. Additionally, the system process may be single threaded. These factors can thus create a scaling bottle neck on systems with a high rate of processes being given to, or adopted by, the system process. The existence of uncollected, “orphaned” processes can consume system resources, including memory, result in enlarging data structures (process entries, thread table entries, etc.), and so forth, which can diminish a system's performance.
A process has responsibilities such as starting (e.g., “spawning”) a new process and restarting (e.g., “respawning”) processes that have ended or improperly gone away. As mentioned above, a process will have one or more threads, e.g., sets of instructions being executed by a single physical processor. A system process, such as the “init” process in Unix semantics, is responsible for initializing a system, but additionally has its own set of responsibilities, like any other process, for starting new processes and restarting processes that have ended or improperly gone away. For example, a system process may have the responsibility for starting a web server, among other things, and restarting the web server when it has improperly ended or exited.
A process is not responsible for restarting another process which it did not create. Thus, if as describe above, a parent process goes away or end before its child process, the child process will not be restarted by another process. A process, however, can clean up or remove a process which it did not create. A system process is usually responsible for cleaning up (e.g. adopting) these “orphaned” processes. The system process knows when an orphaned process has been turned over to it for cleaning up. That is, the orphaned process is marked or flagged as having been handed over to the system process. As one of ordinary skill in the art will appreciate upon reading this disclosure, this can occur in a code path of the “kernel” operating system. This is true whether the operating system is a Unix, Linux, AIX, or Mac based operating system, etc.
When a system process begins it will have one or more threads of execution for a single physical processor. According to embodiments of the present invention, when the system process begins it additionally starts at least one thread of execution which can run on another physical processor separate from its other responsibilities, e.g., threads of execution. This at least one additional thread is responsible for cleaning up the orphaned processes that have been turned over to the system process. When a child process is orphaned to the system process, its structure is marked with a flag as having been “adopted” by the system process at the time the parent process is changed. This new flag will only be used by the system process. When the flag is used, the system process will only reap adopted children processes that have terminated. The additional thread responsible for cleaning up this the orphaned processes that have been turned over to the system process will have no other purpose than cleaning up these adopted children processes that have terminated. The at least one additional thread will be referred to herein as a “orphan collector thread” (OCT). When the OCT wants to clean up orphaned processes it makes a call to the system to “wait on” the orphaned processes. According to the various embodiments, the OCT is only responsible for collecting orphaned processes. As such, the OCT can be contained in a very tight segment of code on the order of tens of lines of codes versus thousands and be run in more approximately real time than threads with which possess multiple responsibilities. A threshold can be established, and selectably varied by user input, such that the OCT will “wait on” orphaned processes only after a requisite number of orphaned processes have been turned over to the system process. Further, more than one OCT can be started by the system process based on another threshold, also selectably variable by user input, such that the number of OCT's in existence is responsive to various volumes of orphaned processes.
In the following description, for purposes of explanation, numerous details are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to one skilled in the art that these specific details are not required in order to practice the present invention. In other instances, well known electrical structures and circuits are shown in block diagram form in order not to obscure the present invention.
As noted above and discussed more in connection with
Fixed mass storage can include hard disk drives and removable mass storage can include non-volatile and volatile memory such as Flash memory, compact disks (CDs), floppy disks, portable memory keys, and other magnetic and/or optical memory mediums, etc. Embodiments are not limited to these examples.
Network interfaces 110 can include internet connections as well as intranets, local area networks (LANs), enterprise networks, wide area networks (WANs), etc., whether wirelessly accessed or otherwise. Network interfaces 110 allow the number of processors 102-1, 102-2, . . . , 102-N to be connected to other computers, e.g., laptops, workstations, desktops, servers, etc., and computer networks, or telecommunications network using various network connection types and associated protocols as one of ordinary skill in the art will appreciate upon reading this disclosure.
The number of processors 102-1, 102-2, . . . , 102-N can receive information, e.g., data objects or program instructions, from another network and can output information to other network in connection with performing embodiments discussed herein. One of ordinary skill in the art will further appreciate that information in the form of computer executable instructions may be embodied in a carrier wave.
When a parent goes away, e.g., terminates, and it still has children in existence, the children processes are “adopted” by a system process. Similarly, “orphaned” children processes are adopted by the system process if a parent process indicates that it will not “clean up” its children. In other words, a system process is assigned the responsibility of cleaning up orphaned children processes which it did not start. The system process does not attempt to restart processes which it did not create.
As one of ordinary skill in the art will appreciate from reading this disclosure, the system process has many responsibilities to handle. As a result, the responsibility to “wait on” orphaned processes may be low on the system process' priority list. The same reader will appreciate that some parent processes may have as their responsibility the task of spawning/starting many children processes (e.g., 10-500 children processes) and then go away. Thus, an accumulating number of orphaned processes lying around and awaiting to be cleaned up by the system process may begin to interfere with a system's performance such that a system no longer performs at its full potential. Embodiments of the present invention rectify this potential situation as discussed further in connection with
According to various embodiments the one or more secondary threads, 211-1, 211-2, . . . , 211-O, can run, e.g., execute, as posix real time threads on a global system wide list, as the same will be known and understood by one of ordinary skill in the art, rather than being assigned to one particular processor. In this manner, the one or more secondary threads, 211-1, 211-2, . . . , 211-O, can run, e.g., execute, as higher priority process specific threads than if they were awaiting a single processor being used by other threads of the system process 201-3.
According to various embodiments, when the one or more secondary threads, 211-1, 211-2, . . . , 211-O, want to clean up orphaned children processes these one or more secondary threads, 211-1, 211-2, . . . , 211-O, can run, e.g., execute, a function call to wait on the orphaned children processes. Since the one or more secondary threads, 211-1, 211-2, . . . , 211-O, are dedicated to cleaning up orphaned children threads they can be written in a more tight segment of code, e.g., tens (10s) of lines of code, in comparison to threads which are written as sets of instruction with multiple responsibilities. In other words, once a secondary thread, which will be referred to herein as an orphan collector thread (OCT), has executed to clean up accumulated orphaned threads it has no further responsibilities and can return to an “idle” state.
As one of ordinary skill in the art will appreciate upon reading this disclosure, the one or more secondary threads, 211-1, 211-2, . . . , 211-O, can run, e.g., execute, according the a thresholding scheme. That is, the system process 201-3 can maintain and track, e.g., store and reference in its process data, the number of orphaned children processes which have been given over to it, e.g., adopted, as well as when they were adopted, e.g., how long various orphaned children process have been waiting to be cleaned up. According to various embodiments, the one or more secondary threads, 211-1, 211-2, . . . , 211-O, can run, e.g., execute, a function call to the wait on the orphaned children processes once various, user selectable, orphaned children process count thresholds have been reached. For example, as will be discussed in more detail below, one secondary orphan collector thread (OCT) can be started as the system process is initiated and that OCT can hold off on making a function call to wait on orphaned children processes until a designated first threshold count has been reached, e.g., once more than 200 orphaned children processes are awaiting to be cleaned up. In this manner, the embodiments will defray any concern over creating system perturbations due to OCTs executing on additional separate physical processors in more real time than in awaiting execution on the particular processor which the system process' 201-1 primary threads are executing. As will be discussed below, various additional, user selectable, count threshold can be established at which time the system process will start additional OCTs.
One of ordinary skill in the art will appreciate upon reading this disclosure the manner in which various, user selectable, count threshold can be implemented with the embodiments of the system process described herein. Another advantage to the ability to implement various, user selectable, count thresholds is that the various count thresholds can be scaled by user input as suitable to various systems and operating conditions. For example, to check the efficacy of the one or more secondary threads, 211-1, 211-2, . . . , 211-O, the thresholds can be set lower and/or higher during a particular “testing” operation in order to aggressively execute function calls ability and response to wait on orphaned children process and/or evaluate a impact to performance on the system at higher count thresholds. Similarly, then the count thresholds can be adjusted lower and/or higher to particular customer and/or productions specifications.
As shown in
As another advantage to the various system process embodiments the system process can have another thresholding hierarchy associated with how long an OCT executes to clean up orphaned children processes. For example, at various, user selectable, numbers of cleaned up orphaned children by a given OCT the OCT can execute a function call to pause cleaning up the orphaned children processes thereby releasing system resources, e.g., freeing a particular processor, etc. In this manner, by forcibly giving up a processor once in a while a real time thread will be able to block in the kernel operating system for a significant time period, within the various threshold described above, such that the OCT does not bounce around to an extensive degree. One of ordinary skill in the art will appreciate upon reading this disclosure the manner in which a thresholding hierarchy associated with how long an OCT executes to clean up orphaned children processes, according to various, user selectable thresholds, can be implemented with the embodiments of the system process described herein.
That is, if three threads (e.g., labeled for convenience in a processing order as A, B, and C and having equal priority) are all eligible to run at the same time, A will be selected first to run, occupying a processor resource until it is through, then thread B will have access to the processor next, and then once thread B is through thread C will have access to the processor resource.
For comparison,
One of ordinary skill in the art will appreciate from reading this disclosure that the system process embodiments of the present invention can reduce this above described occurrence of priority inversion. The system process embodiments described herein start and dedicate secondary OCTs which can execute on additional physical processors from the particular processor being used by the system process' primary threads, e.g., other responsibilities. The dedicated OCTs are provided with thresholding to avoid perturbing the system's load and to release processor resources from time to time. The secondary OCTs can be written in a much smaller code space than used for threads having other responsibilities.
Unless explicitly stated, the method embodiments described herein are not constrained to a particular order or sequence. Additionally, some of the described method embodiments or elements thereof can occur or be performed at the same point in time.
The system process of a given operating system is typically also given the responsibility of cleaning up children processes which were not cleaned up by their parent processes. Processes make function calls to the system operating system which call one or more subroutines and execute instructions to accomplish these tasks. In the Unix example, a process is to be “waited on” (e.g., cleaned up after) by its parent. If the parent exits and fails to do this, the process is then adopted by the “init” process (a system daemon), which is then responsible for cleaning up (e.g., reaping) all orphaned children processes on the system that were not reaped by their parent. One of ordinary skill in the art will appreciate upon reading this disclosure that in such a process management subsystem, when a process is orphaned to init, its structure can be marked as having been “adopted” at the time the parent process is changed.
When a process is given to init its structure can be marked as “p_adopted_by_init.” While init remains with a single list of children, one of ordinary skill in the art will appreciate it is easy to identify with some reasonable degree of accuracy which children processes init actually started and which ones it did not. In Unix example, the init process would be single threaded and have restrictions placed on its scheduling priorities thus creating a scaling bottleneck on systems with a high rate of processes being given to Unix.
Accordingly, as shown in block 420, the method embodiment of
By way of example and not by way of limitation, the following particular implementation of this method embodiment is described with reference to Unix. In “kernel space” the process management system will provide a new flag to the init, as the same will be appreciated by one of ordinary skill in the art. This flag is both specifically and only for init, e.g., the system process.
That is, this new flag will only be used for init, e.g., the system process. When this flag is used, the system process will only reap, e.g., clean up, adopted children processes which have terminated, e.g., inherited terminated children processes of init. The system process using this flag will have no other purpose than cleaning up inherited terminated children processes. For example, the OCT will call wait/waitpid with this new flag to clean up orphaned children processes. As one of ordinary skill in the art will appreciate upon reading this disclosure, due to this new flag, the OCT will only select processes that were “adopted” by init. Hence, anything the OCT reaps will not need to be respawned. In this manner, the OCT can avoid all need for “user space” to synchronize around threads which do, and do not need to be respawned.
According to various embodiments, discussed herein, the new flag can be associated with one or more threshold. That is, as an over load of this flag, it will only reap when init is having difficulty collecting an accumulating number of orphaned children processes, e.g., once a certain number count (which can be user selectable) of orphaned children processes have been adopted but not yet cleaned up. When init is not having difficulty collecting, e.g., cleaning up, orphaned processes, the OCT will block for a period of time, and then check again. By way of example and not by way of limitation using the Unix example, if after a certain numbered (e.g., second or otherwise) subsequent check fails (e.g., init still does not need help), the OCT can return to ESRCH, as the same will be understood by one of ordinary skill in the art. One of ordinary skill in the art will appreciate that such a design will avoid having the OCT be called and then remaining in kernel space an inordinate amount of time. One of ordinary skill in the art will further appreciate that since some things only happen upon going out to user space, it is desirable to ensure that the transition to user space occurs on some reasonable interval.
In a user space portion, at start up init spawns a second (and possibly third, or greater number) thread. This new thread (referred to herein as OCT) first sets itself to realtime, and then masks off most signals, leaving only the unmaskable, and some like SIGSEGV enabled, as the same will be understood by one of ordinary skill in the art. In various embodiments, the OCT is a portable operating system interface for Unix (posix) thread on a global system wide list. This OCT will sit in a loop calling wait with the new flag. Every “N”, for some arbitrary value of N, successful calls it will call nanosleep(1). This call to nanosleep ensures that as an realtime thread, the OCT forcibly gives up the processor once in a while. The OCT will block in the kernel for a measurable time period if its assistance for cleaning up orphaned children processes is unnecessary, ensuring the OCT does not unnecessarily bounce around. For example, the OCT will only wait on orphaned children processes once certain thresholds have been reached. The kernel can alter the levels, e.g. thresholds, of when init considered to be having difficulty (e.g., “in trouble”) collecting the orphaned children processes based on the flavor of the kernel, e.g., as suited to the particular choice of operating conditions. One of ordinary skill in the art will appreciate that this permits better code coverage by having init be “in trouble” almost all of the time during testing operating conditions. Along with altering the thresholds, the kernel can start one or more additional OCTs to wait on orphaned processes once one or more second thresholds have been reached. These thresholds can all be variably established based on user input.
As shown at block 510, the OCT will execute a function call to clean up orphaned children processes only after a selectable number of “non-reaped” orphaned children processes have been adopted by the system process. According to various embodiments the method includes using the OCT to wait on orphaned processes once a first threshold has been reached. One of ordinary skill in the art will appreciate that the first threshold can be variably established based on user input. In the various embodiments the first threshold is associated with a number representing how many orphaned processes have been given to the system process. One or more additional OCTs can be started to wait on orphaned processes once one or more second thresholds have been reached. Similarly, the one or more second thresholds can be variably established based on user input. And, in various embodiments the one or more second thresholds are associated with one or more additional numbers representing how many orphaned processes have been given to the system process. As has been described herein, additional thresholds can be established according to the system process embodiments such that a particular OCT will release a processor resource being used to clean up orphaned children processes after a selectable number of orphaned children processes have been cleaned up. As described above, the OCT becomes idle when the OCT is not cleaning up orphaned children processes.
Although specific embodiments have been illustrated and described herein, those of ordinary skill in the art will appreciate that any arrangement calculated to achieve the same techniques can be substituted for the specific embodiments shown. This disclosure is intended to cover any and all adaptations or variations of various embodiments of the invention. It is to be understood that the above description has been made in an illustrative fashion, and not a restrictive one. Combination of the above embodiments, and other embodiments not specifically described herein will be apparent to those of skill in the art upon reviewing the above description. The scope of the various embodiments of the invention includes any other applications in which the above structures and methods are used. Therefore, the scope of various embodiments of the invention should be determined with reference to the appended claims, along with the full range of equivalents to which such claims are entitled.
In the foregoing Detailed Description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the embodiments of the invention require more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive subject matter lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby incorporated into the Detailed Description, with each claim standing on its own as a separate embodiment.
This application claims the benefit of U.S. Provisional Application No. 60/587,445, filed Jul. 13, 2004, the entire content of which is incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
60587445 | Jul 2004 | US |