sched.cpp 760 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <errno.h>
  7. #include <sched.h>
  8. #include <syscall.h>
  9. extern "C" {
  10. int sched_yield()
  11. {
  12. int rc = syscall(SC_yield);
  13. __RETURN_WITH_ERRNO(rc, rc, -1);
  14. }
  15. int sched_get_priority_min([[maybe_unused]] int policy)
  16. {
  17. return 0; // Idle
  18. }
  19. int sched_get_priority_max([[maybe_unused]] int policy)
  20. {
  21. return 3; // High
  22. }
  23. int sched_setparam(pid_t pid, const struct sched_param* param)
  24. {
  25. int rc = syscall(SC_sched_setparam, pid, param);
  26. __RETURN_WITH_ERRNO(rc, rc, -1);
  27. }
  28. int sched_getparam(pid_t pid, struct sched_param* param)
  29. {
  30. int rc = syscall(SC_sched_getparam, pid, param);
  31. __RETURN_WITH_ERRNO(rc, rc, -1);
  32. }
  33. }