sched.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*++
  2. Copyright (c) 2016 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. sched.c
  9. Abstract:
  10. This module implements scheduling functionality for the C library.
  11. Author:
  12. Chris Stevens 11-Jul-2016
  13. Environment:
  14. User Mode C Library.
  15. --*/
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. #include "libcp.h"
  20. #include <sched.h>
  21. #include <errno.h>
  22. //
  23. // ---------------------------------------------------------------- Definitions
  24. //
  25. //
  26. // ------------------------------------------------------ Data Type Definitions
  27. //
  28. //
  29. // ----------------------------------------------- Internal Function Prototypes
  30. //
  31. //
  32. // -------------------------------------------------------------------- Globals
  33. //
  34. //
  35. // ------------------------------------------------------------------ Functions
  36. //
  37. LIBC_API
  38. int
  39. sched_yield (
  40. void
  41. )
  42. /*++
  43. Routine Description:
  44. This routine causes the current thread to yield execution of the processor.
  45. Arguments:
  46. None.
  47. Return Value:
  48. 0 on success.
  49. -1 on error, and the errno variable will contain more information.
  50. --*/
  51. {
  52. KSTATUS Status;
  53. //
  54. // A zero second delay is equivalent to a yield.
  55. //
  56. Status = OsDelayExecution(FALSE, 0);
  57. if (!KSUCCESS(Status)) {
  58. errno = ClConvertKstatusToErrorNumber(Status);
  59. return -1;
  60. }
  61. return 0;
  62. }
  63. //
  64. // --------------------------------------------------------- Internal Functions
  65. //