1. A method of executing code, the method comprising: performing, by said code during execution of said code, a call using an application programming interface requesting a first of a plurality of operations, said plurality of operations corresponding to scheduling and synchronization primitives which are operations performed on different scheduling objects; determining, during runtime in response to said call, whether to perform said first operation, said determining using a set of one or more criteria indicating conditions as to when said scheduling and synchronization primitives are allowed to be performed, said one or more criteria being determined in accordance with a plurality of different platforms, wherein said plurality of operations are performed in accordance with a set of semantics specified using the set of one or more criteria whereby each of said plurality of operations, when executed in accordance with said set of one or more criteria, exhibits a same runtime behavior when executed in a privileged execution mode and a non-privileged execution mode on each of said different platforms; and invoking code of the application programming interface to register a device driver executing in the non-privileged execution mode and including an interrupt service routine that services interrupts for a device and executes in the non-privileged execution mode, wherein a reader-writer lock is used by code that executes in the non-privileged execution mode to implement disabling and enabling interrupts in accordance with semantics of the privileged execution mode, wherein one or more readers are allowed read access to the read-write lock when not already accessed for writing and wherein a writer with write access to the read-write lock has exclusive access to the read-write lock.