-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsched.h
More file actions
39 lines (31 loc) · 894 Bytes
/
Copy pathsched.h
File metadata and controls
39 lines (31 loc) · 894 Bytes
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
#ifndef _SCHED_H_
#define _SCHED_H_
#define STACK_SIZE 512
#define WORD_SIZE 4
#define CPSR 0x13
#define NULL ((void*)0)
typedef enum {READY, SLEEPING, EXECUTING, ZOMBIE} etat;
typedef void (*func_t) ( void*);
typedef struct ctx_s {
unsigned int sp;
void *lr;
} ctx_s;
typedef struct pcb_s {
etat etat;
struct ctx_s context;
struct pcb_s * next;
func_t func_pointer;
void* args;
}pcb_s;
/*struct ctx_s* current_ctx;*/
void init_ctx(struct ctx_s* ctx, func_t f, unsigned int stack_size);
void __attribute__ ((naked)) switch_to(struct ctx_s* ctx);
void init_pcb(struct pcb_s* pcb, func_t f, void *args, unsigned int stack_size);
void create_process(func_t f, void *args, unsigned int stack_size);
void start_current_process();
void elect();
void ctx_switch_from_irq ();
void start_sched();
void clear_next_process();
void __attribute__ ((naked)) ctx_switch();
#endif