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

87 lines
1.1 KiB

12 years ago
  1. #include <defs.h>
  2. #include <syscall.h>
  3. #include <stdio.h>
  4. #include <ulib.h>
  5. #include <stat.h>
  6. #include <string.h>
  7. #include <lock.h>
  8. static lock_t fork_lock = INIT_LOCK;
  9. void
  10. lock_fork(void) {
  11. lock(&fork_lock);
  12. }
  13. void
  14. unlock_fork(void) {
  15. unlock(&fork_lock);
  16. }
  17. void
  18. exit(int error_code) {
  19. sys_exit(error_code);
  20. cprintf("BUG: exit failed.\n");
  21. while (1);
  22. }
  23. int
  24. fork(void) {
  25. return sys_fork();
  26. }
  27. int
  28. wait(void) {
  29. return sys_wait(0, NULL);
  30. }
  31. int
  32. waitpid(int pid, int *store) {
  33. return sys_wait(pid, store);
  34. }
  35. void
  36. yield(void) {
  37. sys_yield();
  38. }
  39. int
  40. kill(int pid) {
  41. return sys_kill(pid);
  42. }
  43. int
  44. getpid(void) {
  45. return sys_getpid();
  46. }
  47. //print_pgdir - print the PDT&PT
  48. void
  49. print_pgdir(void) {
  50. sys_pgdir();
  51. }
  52. void
  53. lab6_set_priority(uint32_t priority)
  54. {
  55. sys_lab6_set_priority(priority);
  56. }
  57. int
  58. sleep(unsigned int time) {
  59. return sys_sleep(time);
  60. }
  61. unsigned int
  62. gettime_msec(void) {
  63. return (unsigned int)sys_gettime();
  64. }
  65. int
  66. __exec(const char *name, const char **argv) {
  67. int argc = 0;
  68. while (argv[argc] != NULL) {
  69. argc ++;
  70. }
  71. return sys_exec(name, argc, argv);
  72. }