《操作系统》的实验代码。
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.

33 rivejä
742 B

10 vuotta sitten
  1. #include <stdio.h>
  2. #include <ulib.h>
  3. #define ARRAYSIZE (1024*1024)
  4. uint32_t bigarray[ARRAYSIZE];
  5. int
  6. main(void) {
  7. cprintf("Making sure bss works right...\n");
  8. int i;
  9. for (i = 0; i < ARRAYSIZE; i ++) {
  10. if (bigarray[i] != 0) {
  11. panic("bigarray[%d] isn't cleared!\n", i);
  12. }
  13. }
  14. for (i = 0; i < ARRAYSIZE; i ++) {
  15. bigarray[i] = i;
  16. }
  17. for (i = 0; i < ARRAYSIZE; i ++) {
  18. if (bigarray[i] != i) {
  19. panic("bigarray[%d] didn't hold its value!\n", i);
  20. }
  21. }
  22. cprintf("Yes, good. Now doing a wild write off the end...\n");
  23. cprintf("testbss may pass.\n");
  24. bigarray[ARRAYSIZE + 1024] = 0;
  25. asm volatile ("int $0x14");
  26. panic("FAIL: T.T\n");
  27. }