Patent ID: 7712105

Claim:
A method for enabling multiple software applications to use a random number generator (RNG) in a microprocessor that is executing a multitasking operating system (OS) that does not provide for saving and restoring state of the RNG to a memory during task switches, the method comprising: a first task loading an RNG register and a non-RNG register with a first value; the RNG generating random data based on said first value in said RNG register; the OS saving said first value from said non-RNG register to the memory coupled to the microprocessor when the OS performs a task switch from said first task to a second task; the second task loading said RNG register and the non-RNG register with a second value after the OS saving said first value; the RNG generating random data based on said second value in said RNG register; the OS restoring said first value from said memory to said non-RNG register when the OS performs a task switch from said second task to said first task; the RNG setting a flag to indicate occurrence of a possible task switch in response to the OS restoring said first value from said memory to said non-RNG register; said first task executing an instruction requesting storage of random data after the RNG setting said flag; the RNG determining whether said flag is set after said first task executing said instruction; the RNG copying said first value from said non-RNG register to said RNG register after the OS restoring said first value from said memory to said non-RNG register; and the RNG generating random data based on said first value after said RNG copying said first value.