《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
473 B

10 years ago
  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. }