《操作系统》的实验代码。

22 líneas
473 B

hace 12 años
  1. #include <stdio.h>
  2. #include <ulib.h>
  3. int
  4. main(void) {
  5. int pid, exit_code;
  6. if ((pid = fork()) == 0) {
  7. cprintf("fork ok.\n");
  8. int i;
  9. for (i = 0; i < 10; i ++) {
  10. yield();
  11. }
  12. exit(0xbeaf);
  13. }
  14. assert(pid > 0);
  15. assert(waitpid(-1, NULL) != 0);
  16. assert(waitpid(pid, (void *)0xC0000000) != 0);
  17. assert(waitpid(pid, &exit_code) == 0 && exit_code == 0xbeaf);
  18. cprintf("badarg pass.\n");
  19. return 0;
  20. }