Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. delay.c
  5. Abstract:
  6. This module implements the executive delay execution system service.
  7. Author:
  8. David N. Cutler (davec) 13-May-1989
  9. Environment:
  10. Kernel mode only.
  11. Revision History:
  12. --*/
  13. #include "exp.h"
  14. #ifdef ALLOC_PRAGMA
  15. #pragma alloc_text(PAGE, NtDelayExecution)
  16. #endif
  17. NTSTATUS
  18. NtDelayExecution (
  19. IN BOOLEAN Alertable,
  20. IN PLARGE_INTEGER DelayInterval
  21. )
  22. /*++
  23. Routine Description:
  24. This function delays the execution of the current thread for the specified
  25. interval of time.
  26. Arguments:
  27. Alertable - Supplies a boolean value that specifies whether the delay
  28. is alertable.
  29. DelayInterval - Supplies the absolute of relative time over which the
  30. delay is to occur.
  31. Return Value:
  32. NTSTATUS.
  33. --*/
  34. {
  35. LARGE_INTEGER Interval;
  36. KPROCESSOR_MODE PreviousMode;
  37. //
  38. // Establish an exception handler and probe delay interval address. If
  39. // the probe fails, then return the exception code as the service status.
  40. // Otherwise return the status value returned by the delay execution
  41. // routine.
  42. //
  43. // Get previous processor mode and probe delay interval address if
  44. // necessary.
  45. //
  46. PreviousMode = KeGetPreviousMode();
  47. if (PreviousMode != KernelMode) {
  48. try {
  49. ProbeForReadSmallStructure (DelayInterval, sizeof(LARGE_INTEGER), sizeof(ULONG));
  50. Interval = *DelayInterval;
  51. } except(EXCEPTION_EXECUTE_HANDLER) {
  52. return GetExceptionCode();
  53. }
  54. }
  55. else {
  56. Interval = *DelayInterval;
  57. }
  58. //
  59. // Delay execution for the specified amount of time.
  60. //
  61. return KeDelayExecutionThread(PreviousMode, Alertable, &Interval);
  62. }