process.h 960 B

12345678910111213141516171819202122232425262728293031323334353637
  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 0x40000 /* 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 process {
  14. unsigned int esp;
  15. unsigned int state;
  16. unsigned int pid;
  17. char name[PROC_NAME_LEN];
  18. };
  19. extern struct process procs[MAX_PROCS];
  20. extern volatile unsigned int current_pid;
  21. void process_init(void);
  22. int process_create(const char *name, void (*entry)(void));
  23. int process_create_arg(const char *name, void (*entry)(const char *),
  24. const char *arg);
  25. void process_exit(void);
  26. void schedule(void);
  27. void process_ps(void);
  28. int process_kill(unsigned int pid);
  29. #endif