process.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Preemptive round-robin multitasking for i586, ring-0 only. */
  2. #ifndef PROCESS_H
  3. #define PROCESS_H
  4. #define MAX_PROCS 8
  5. #define PROC_STACK_SIZE 0x1000 /* 4 KB per process */
  6. #define PROC_STACK_BASE 0x42000 /* process 1 stack bottom; process 0 uses bootstrap stack */
  7. #define PROC_UNUSED 0
  8. #define PROC_READY 1
  9. #define PROC_RUNNING 2
  10. #define PROC_DEAD 3
  11. #define TIMESLICE_TICKS 20 /* context switch every 20 ms (PIT @ 1 kHz) */
  12. #define PROC_NAME_LEN 12
  13. struct text_screen; /* forward decl (see screen.h) */
  14. struct process {
  15. unsigned int esp;
  16. unsigned int state;
  17. unsigned int pid;
  18. char name[PROC_NAME_LEN];
  19. struct text_screen *screen; /* output target for io_putchar & co. */
  20. };
  21. extern struct process procs[MAX_PROCS];
  22. extern volatile unsigned int current_pid;
  23. void process_init(void);
  24. int process_create(const char *name, void (*entry)(void));
  25. int process_create_arg(const char *name, void (*entry)(const char *),
  26. const char *arg);
  27. int process_create_ptr(const char *name, void (*entry)(void *), void *arg);
  28. void process_set_screen(struct text_screen *screen);
  29. void process_exit(void);
  30. void schedule(void);
  31. void process_ps(void);
  32. int process_kill(unsigned int pid);
  33. int process_is_alive(unsigned int pid);
  34. void process_wait(unsigned int pid);
  35. #endif