Subversion Repositories freemyipod

Rev

Rev 14 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14 Rev 15
Line 53... Line 53...
53
{
53
{
54
    THREAD_FREE = 0,
54
    THREAD_FREE = 0,
55
    THREAD_READY,
55
    THREAD_READY,
56
    THREAD_RUNNING,
56
    THREAD_RUNNING,
57
    THREAD_BLOCKED,
57
    THREAD_BLOCKED,
58
    THREAD_SUSPENDED
58
    THREAD_SUSPENDED,
-
 
59
    THREAD_DEFUNCT,
-
 
60
    THREAD_DEFUNCT_ACK
59
};
61
};
60
 
62
 
61
enum thread_block
63
enum thread_block
62
{
64
{
63
    THREAD_NOT_BLOCKED = 0,
65
    THREAD_NOT_BLOCKED = 0,
64
    THREAD_BLOCK_SLEEP,
66
    THREAD_BLOCK_SLEEP,
65
    THREAD_BLOCK_MUTEX,
67
    THREAD_BLOCK_MUTEX,
66
    THREAD_BLOCK_WAKEUP
68
    THREAD_BLOCK_WAKEUP,
-
 
69
    THREAD_DEFUNCT_STKOV
-
 
70
};
-
 
71
 
-
 
72
enum thread_type
-
 
73
{
-
 
74
    USER_THREAD = 0,
-
 
75
    SYSTEM_THREAD
67
};
76
};
68
 
77
 
69
struct scheduler_thread
78
struct scheduler_thread
70
{
79
{
71
    uint32_t regs[16];
80
    uint32_t regs[16];
Line 79... Line 88...
79
    uint32_t blocked_since;
88
    uint32_t blocked_since;
80
    void* blocked_by;
89
    void* blocked_by;
81
    uint32_t* stack;
90
    uint32_t* stack;
82
    enum thread_state state;
91
    enum thread_state state;
83
    enum thread_block block_type;
92
    enum thread_block block_type;
-
 
93
    enum thread_type type;
84
    uint8_t priority;
94
    uint8_t priority;
85
    uint8_t cpuload;
95
    uint8_t cpuload;
86
};
96
};
87
 
97
 
88
struct mutex
98
struct mutex
Line 100... Line 110...
100
 
110
 
101
 
111
 
102
void scheduler_init() INITCODE_ATTR;
112
void scheduler_init() INITCODE_ATTR;
103
void scheduler_switch(int thread) ICODE_ATTR;
113
void scheduler_switch(int thread) ICODE_ATTR;
104
int thread_create(const char* name, const void* code, void* stack,
114
int thread_create(const char* name, const void* code, void* stack,
105
                  int stacksize, int priority, bool run);
115
                  int stacksize, enum thread_type type, int priority, bool run);
106
int thread_suspend(int thread);
116
int thread_suspend(int thread);
107
int thread_resume(int thread);
117
int thread_resume(int thread);
108
int thread_terminate(int thread);
118
int thread_terminate(int thread);
109
void thread_exit();
119
void thread_exit();
110
void mutex_init(struct mutex* obj) ICODE_ATTR;
120
void mutex_init(struct mutex* obj) ICODE_ATTR;