Fix improper interruption of sleep
This commit is contained in:
+11
-11
@@ -41,20 +41,19 @@ void timer_add_sleep(struct thread *thr) {
|
||||
|
||||
void timer_remove_sleep(struct thread *thr) {
|
||||
//if (thr->pid > 0)
|
||||
//kdebug("Removing sleep %d\n", thr->pid);
|
||||
uintptr_t irq;
|
||||
struct io_notify *n = &thr->sleep_notify;
|
||||
struct io_notify *it;
|
||||
//struct io_notify *n = &thr->sleep_notify;
|
||||
//struct io_notify *it;
|
||||
spin_lock_irqsave(&g_sleep_lock, &irq);
|
||||
list_for_each_entry(it, &g_sleep_head, link) {
|
||||
if (it == n) {
|
||||
list_del_init(&it->link);
|
||||
spin_release_irqrestore(&g_sleep_lock, &irq);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//list_for_each_entry(it, &g_sleep_head, link) {
|
||||
// if (it == n) {
|
||||
// list_del_init(&it->link);
|
||||
// spin_release_irqrestore(&g_sleep_lock, &irq);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
list_del_init(&thr->sleep_notify.link);
|
||||
spin_release_irqrestore(&g_sleep_lock, &irq);
|
||||
panic("No such thread\n");
|
||||
}
|
||||
|
||||
static uint32_t timer_tick(void *arg) {
|
||||
@@ -90,6 +89,7 @@ static uint32_t timer_tick(void *arg) {
|
||||
struct thread *t = n->owner;
|
||||
|
||||
if (!t) {
|
||||
kdebug("Cleaning up ownerless sleep\n");
|
||||
list_del_init(iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -609,8 +609,6 @@ void process_signal(struct process *proc, int signum) {
|
||||
|
||||
if (thr->sleep_notify.owner) {
|
||||
thread_notify_io(&thr->sleep_notify);
|
||||
//thr->sleep_notify.owner = NULL;
|
||||
//timer_remove_sleep(thr);
|
||||
}
|
||||
|
||||
if (thr->cpu == (int) get_cpu()->processor_id) {
|
||||
|
||||
+4
-4
@@ -123,13 +123,13 @@ void thread_wait_io_clear(struct thread *t) {
|
||||
}
|
||||
|
||||
int thread_sleep(struct thread *thr, uint64_t deadline, uint64_t *int_time) {
|
||||
// Cancel previous sleep
|
||||
list_del_init(&thr->sleep_notify.link);
|
||||
thr->sleep_notify.value = 0;
|
||||
|
||||
thr->sleep_deadline = deadline;
|
||||
timer_add_sleep(thr);
|
||||
return thread_wait_io(thr, &thr->sleep_notify);
|
||||
//// Store time when interrupt occured
|
||||
//if (int_time) {
|
||||
// *int_time = system_time;
|
||||
//}
|
||||
}
|
||||
|
||||
static int wait_check_pid(struct process *chld, int flags) {
|
||||
|
||||
Reference in New Issue
Block a user