OS2021_Project1.Shell
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

106 rindas
3.0 KiB

pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
pirms 3 gadiem
  1. #pragma once
  2. #define CMDLINE_MAX_SIZE 1024 /* max length of a single command line */
  3. #define ARGS_MAX_QUANTITY 128 /* max args on a command line */
  4. #define BUFFER_MAX_SIZE 64 /* max size of a buffer which contains parsed arguments */
  5. #define CMDLINE_DIV ' \t\r\n\a'
  6. #define CMDLINE_HISTORY_MAX_QUANTITY 256
  7. #define JOBS_MAX_QUANTITY 16
  8. #define PATH_MAX_SIZE 256
  9. #define LS_BUF_SIZE 1024
  10. #define REDIRECT_FILENAME_MAX_SIZE 64 /* redirection filename */
  11. #define REDIRECT_ARG_MAX_SIZE 16 /* redirection argument */
  12. #define REDIRECT_NO 0 /* no redirection */
  13. #define REDIRECT_OUT 1 /* redirect output */
  14. #define REDIRECT_IN 2 /* redirect input */
  15. #define _PATH_PROC "/proc/"
  16. const char *cputimenames[] = {"user", "ipc", "kernelcall"};
  17. #define CPUTIMENAMES (sizeof(cputimenames) / sizeof(cputimenames[0]))
  18. #define CPUTIME(m, i) (m & (1L << (i)))
  19. #define PSINFO_VERSION 0
  20. #define TYPE_TASK 'T'
  21. #define TYPE_SYSTEM 'S'
  22. #define TYPE_USER 'U'
  23. #define STATE_RUN 'R'
  24. #define TIMECYCLEKEY 't'
  25. #define ORDERKEY 'o'
  26. #define USED 0x1
  27. #define IS_TASK 0x2
  28. #define IS_SYSTEM 0x4
  29. #define BLOCKED 0x8
  30. #define ORDER_CPU 0
  31. #define ORDER_MEMORY 1
  32. #define ORDER_HIGHEST ORDER_MEMORY
  33. #define TC_BUFFER 1024
  34. #define TC_STRINGS 200
  35. #define _ENDPOINT_P(e) ((((e) + 1023) % (1023 + ((endpoint_t)0x8ace) + 1)) - 1023)
  36. unsigned int nr_procs, nr_tasks;
  37. #define SLOT_NR(e) (_ENDPOINT_P(e) + nr_tasks)
  38. struct proc
  39. {
  40. int p_flags;
  41. endpoint_t p_endpoint;
  42. pid_t p_pid;
  43. u64_t p_cpucycles[CPUTIMENAMES];
  44. int p_priority;
  45. endpoint_t p_blocked;
  46. time_t p_user_time;
  47. vir_bytes p_memory;
  48. uid_t p_effuid;
  49. int p_nice;
  50. char p_name[PROC_NAME_LEN + 1];
  51. };
  52. struct tp
  53. {
  54. struct proc *p;
  55. u64_t ticks;
  56. };
  57. /* readline - Get the command line */
  58. char *readline();
  59. /* parseline - Evaluate the command line that the user has just typed in */
  60. int parseline(char *cmdline, char **args);
  61. /* check_redirect - check if the command contains redirection */
  62. int check_redirect(char **args, char *redirect_filename, char **redirect_args);
  63. /* do_redirect - execute redirection command */
  64. int do_redirect(int redirect_flag, char *redirect_filename, char **redirect_args);
  65. /* check_redirect - check if the command contains pipe */
  66. int check_pipe(char **args, char **pipe_arg_1, char **pipe_arg_2);
  67. /* do_pipe - execute pipe command */
  68. int do_pipe(char **pipe_arg_1, char **pipe_arg_2);
  69. /* do_bgfg - fork and execute background/foreground tasks */
  70. int do_bg_fg(char **args, int bg);
  71. /* execute - Execute the command line */
  72. int execute(char *cmdline, char **args);
  73. /* builtin functions - Handle built-in command */
  74. int built_in(char **args);
  75. int builtin_cd(char **args);
  76. int builtin_history(char **args);
  77. int builtin_mytop();
  78. /* mytop routine */
  79. void mytop_memory();
  80. void mytop_CPU();
  81. void get_procs();
  82. void parse_dir();
  83. void parse_file(pid_t pid);
  84. void getkinfo();
  85. void print_procs(struct proc *proc1, struct proc *proc2, int cputimemode);
  86. u64_t cputicks(struct proc *p1, struct proc *p2, int timemode);