Method and system for distributing asynchronous input from a system input queue to reduce context switches
First Claim
1. In a computer system comprising a processor executing a multithreaded operating system, a memory in which a plurality of threads are loaded, and an input/output device for entering input directed to the threads, a system for reducing context switches when distributing the input to the threads, the system comprising:
- a system input queue for storing input when it is received;
a thread input queue for each thread for storing input directed to the thread;
a system thread for executing code for distributing input from the system input queue to the thread input queue of the thread to which the input is directed;
a synchronization mechanism for the code for distributing input from the system input queue, wherein the system thread must determine whether the synchronization mechanism is already owned before the system thread can begin executing;
a selected thread that owns the synchronization mechanism; and
a mechanism for the selected thread to determine that input has been received in the system input queue and for, in response to input being received, calling the code for distributing input from the selected thread to avoid a context switch.
1 Assignment
0 Petitions
Accused Products
Abstract
A method and system for reducing context switches when distributing input to applications are provided. When input is received, it is stored in a system input queue. A system thread distributes the input stored in the system input queue to appropriate thread input queues. Before the system thread can execute code to process system input, the system thread must obtain ownership of a synchronization mechanism. To eliminate unnecessary context switches, the operating system determines whether the synchronization mechanism is already owned before scheduling the system thread to execute and performing a context switch from the context of the currently executing thread to the context of the system thread. If the synchronization mechanism is not already owned, the system thread is granted ownership and distributes the input stored in the system input queue to the appropriate thread input queues. If the synchronization mechanism is already owned, the thread that already owns the synchronization mechanism distributes the input stored in the system input queue to the appropriate thread input queues.
57 Citations
3 Claims
-
1. In a computer system comprising a processor executing a multithreaded operating system, a memory in which a plurality of threads are loaded, and an input/output device for entering input directed to the threads, a system for reducing context switches when distributing the input to the threads, the system comprising:
-
a system input queue for storing input when it is received; a thread input queue for each thread for storing input directed to the thread; a system thread for executing code for distributing input from the system input queue to the thread input queue of the thread to which the input is directed; a synchronization mechanism for the code for distributing input from the system input queue, wherein the system thread must determine whether the synchronization mechanism is already owned before the system thread can begin executing; a selected thread that owns the synchronization mechanism; and a mechanism for the selected thread to determine that input has been received in the system input queue and for, in response to input being received, calling the code for distributing input from the selected thread to avoid a context switch.
-
-
2. In a computer system comprising a processor executing a multithreaded operating system, a memory in which a plurality of threads are loaded, and an input-output device for entering input directed to the threads, a method for reducing context switches when distributing the input to the threads, the method comprising the steps of:
-
providing a system input queue for storing input when it is received; providing a thread input queue for each thread for storing input directed to the thread; providing a system thread for executing code for distributing input from the system input queue to the thread input queue of the thread to which the input is directed; providing a synchronization mechanism for the code for distributing input from the system input queue, wherein the system thread must determine whether the synchronization mechanism is already owned before the system thread can begin executing; executing the threads on the processor; granting ownership of the synchronization mechanism to a selected one of the threads other than the system thread; entering input directed to an executing thread through the input/output device; when the input is received, storing the input in the system input queue; and with the selected thread, calling the code for distributing input from the system input queue to avoid a context switch.
-
-
3. In a computer system that executes a multi-threaded operating system, wherein the computer system includes an input device for entering input, and a system input queue for holding input from the input device, a method comprising the computer implemented steps of:
-
providing code for distributing input from the system input queue to destinations; providing a system thread that calls the code for distributing input from the system input queue to destinations to clear the input from the system input queue; providing an ownable synchronization mechanism for synchronizing access to the code for distributing input from the system input queue to destinations; granting ownership of the synchronization mechanism to a selected thread; and calling the code for distributing input from the system input queue to destinations from the selected thread if there is input to be distributed in the system input queue.
-
Specification