shim_sched.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * shim_sched.c
  17. *
  18. * Implementation of system call "sched_yield".
  19. */
  20. #include <shim_internal.h>
  21. #include <shim_table.h>
  22. #include <api.h>
  23. #include <pal.h>
  24. #include <errno.h>
  25. int shim_do_sched_yield (void)
  26. {
  27. DkThreadYieldExecution();
  28. return 0;
  29. }
  30. int shim_do_sched_getaffinity (pid_t pid, size_t len,
  31. __kernel_cpu_set_t * user_mask_ptr)
  32. {
  33. int ncpus = PAL_CB(cpu_info.cpu_num);
  34. memset(user_mask_ptr, 0, len);
  35. for (int i = 0 ; i < ncpus ; i++)
  36. ((uint8_t *) user_mask_ptr)[i / 8] |= 1 << (i % 8);
  37. return ncpus;
  38. }