include/cedos/sched/sched.h (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
/*! \file
* Manages the distribution of processing time among processes.
*/
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include <stdint.h>
#include "cedos/sched/process.h"
#include "cedos/mm/paging.h"
#define SCHED_INTERVAL (0xFFFF)
/*!
* Structure of the process stack when the scheduler is executed.
*/
typedef struct {
uint32_t edi;
uint32_t esi;
uint32_t ebp;
uint32_t esp;
uint32_t edx;
uint32_t ecx;
uint32_t ebx;
uint32_t eax;
uint32_t eip;
uint32_t cs;
uint32_t eflags;
}__attribute__((packed)) SCHED_FRAME;
/*!
* Spawns a new process, loads it from the given ELF file, and returns its process ID.
*/
PROCESS_ID sched_spawn(const char *name, char *args, int flags);
/*!
* Return the ID of the current process.
* \return ID of current process.
*/
PROCESS_ID get_current_process(void);
/*!
* Initializes the scheduler.
*/
int sched_init(void);
/*!
* Starts the scheduler.
* \return 1 on success, 0 on failure.
*/
int sched_start(void);
/*!
* Stops the scheduler.
* \return 1 on success, 0 on failure.
*/
int sched_stop(void);
/*!
* Returns processing time to the scheduler prematurely and blocks the
* process for one unit of time.
*/
void sched_yield(void);
/*!
* Kills the process with the specified ID.
* \param pid Process ID of the process to be killed.
* \return 1 on success, 0 on failure.
*/
int sched_kill(PROCESS_ID pid);
/*!
* Wait for a process to terminate.
* \param pid Process ID of the process to wait for.
*/
void sched_wait(PROCESS_ID pid);
/*!
* The scheduler.
*/
void sched_interrupt_c(SCHED_FRAME * volatile frame, uint32_t volatile ebp);
#endif