Patent ID: 8826295

Claim:
A method for adaptive context switching within an apparatus comprising a Central Processing Unit (CPU), the method comprising: requesting, by a process executing within the CPU, an input/output device to perform an input/output of data; calculating a first effectiveness of the CPU, where context switching to a driver context of the input/output device is performed, the calculation being different based on whether or not the device use Direct Memory Access (DMA), the first effectiveness of the CPU including an amount of time allocated to the driver context of the input/output device; calculating a second effectiveness of the CPU, where no context switching is performed and the input/output is directly performed by the process, the second effectiveness of the CPU including an amount of time the CPU is allocated to the process; comparing the first effectiveness of the CPU to the second effectiveness of the CPU; selecting a way to perform the input/output between performing the context switching to a driver context of the input/output device, and directly performing, by the process, the input/output based on a result of the comparison of the first effectiveness of the CPU and the second effectiveness of the CPU; and performing the input/output using the selected way.