sched0.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * This file is part of Jehanne.
  3. *
  4. * Copyright (C) 2016 Giacomo Tesio <giacomo@tesio.it>
  5. *
  6. * Jehanne is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, version 2 of the License.
  9. *
  10. * Jehanne is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <u.h>
  19. #include <lib9.h>
  20. /* verify that the scheduler give each process a chance to run
  21. * with a single cpu (x86) this test do not pass on plan9/9front
  22. * (last check on 2016-10-03).
  23. */
  24. int spin;
  25. void
  26. main(void)
  27. {
  28. sys_rfork(RFNOTEG);
  29. switch(sys_rfork(RFPROC|RFMEM)){
  30. case -1:
  31. exits("sys_rfork");
  32. case 0:
  33. spin = 1;
  34. while(spin)
  35. ;
  36. exits(nil);
  37. default:
  38. while(spin == 0)
  39. ;
  40. }
  41. switch(sys_rfork(RFPROC|RFMEM)){
  42. case -1:
  43. exits("sys_rfork");
  44. case 0:
  45. spin = 2;
  46. while(spin)
  47. ;
  48. exits(nil);
  49. default:
  50. while(spin == 1)
  51. ;
  52. }
  53. spin = 0;
  54. sleep(500);
  55. print("PASS\n");
  56. exits("PASS");
  57. }