Merge branch 'master' into ohligs
This commit is contained in:
commit
b3be0861f9
2 changed files with 18 additions and 2 deletions
|
@ -58,6 +58,7 @@ extern "C" {
|
|||
#define TASK_DEFAULT_FLAGS 0
|
||||
#define TASK_FPU_INIT (1 << 0)
|
||||
#define TASK_FPU_USED (1 << 1)
|
||||
#define TASK_TIMER (1 << 2)
|
||||
|
||||
typedef int (*entry_point_t)(void*);
|
||||
typedef int (STDCALL *internal_entry_point_t)(void*);
|
||||
|
|
|
@ -875,14 +875,27 @@ int wakeup_task(tid_t id)
|
|||
prio = task->prio;
|
||||
core_id = task->last_core;
|
||||
|
||||
if (task_table[id].status == TASK_BLOCKED) {
|
||||
task_table[id].status = TASK_READY;
|
||||
if (task->status == TASK_BLOCKED) {
|
||||
task->status = TASK_READY;
|
||||
ret = 0;
|
||||
|
||||
spinlock_lock(&runqueues[core_id].lock);
|
||||
// increase the number of ready tasks
|
||||
runqueues[core_id].nr_tasks++;
|
||||
|
||||
// do we need to remove from timer queue?
|
||||
if (task->flags & TASK_TIMER) {
|
||||
task->flags &= ~TASK_TIMER;
|
||||
if (task->prev)
|
||||
task->prev->next = task->next;
|
||||
if (task->next)
|
||||
task->next->prev = task->prev;
|
||||
if (runqueues[core_id].timers.first == task)
|
||||
runqueues[core_id].timers.first = task->next;
|
||||
if (runqueues[core_id].timers.last == task)
|
||||
runqueues[core_id].timers.last = task->prev;
|
||||
}
|
||||
|
||||
// add task to the runqueue
|
||||
if (!runqueues[core_id].queue[prio-1].last) {
|
||||
runqueues[core_id].queue[prio-1].last = runqueues[core_id].queue[prio-1].first = task;
|
||||
|
@ -975,6 +988,7 @@ int set_timer(uint64_t deadline)
|
|||
if (curr_task->status == TASK_RUNNING) {
|
||||
curr_task->status = TASK_BLOCKED;
|
||||
curr_task->timeout = deadline;
|
||||
curr_task->flags |= TASK_TIMER;
|
||||
ret = 0;
|
||||
|
||||
spinlock_lock(&runqueues[core_id].lock);
|
||||
|
@ -1197,6 +1211,7 @@ void scheduler(void)
|
|||
runqueues[core_id].timers.first = runqueues[core_id].timers.first->next;
|
||||
if (!runqueues[core_id].timers.first)
|
||||
runqueues[core_id].timers.last = NULL;
|
||||
task->flags &= ~TASK_TIMER;
|
||||
|
||||
// wakeup task
|
||||
if (task->status == TASK_BLOCKED) {
|
||||
|
|
Loading…
Add table
Reference in a new issue