Changeset 5573942 in mainline
- Timestamp:
- 2007-02-04T11:46:18Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 15819e37
- Parents:
- cf5ddf6
- Location:
- kernel/generic
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ddi/irq.h
rcf5ddf6 r5573942 84 84 typedef void (* irq_handler_t)(struct irq *irq, void *arg, ...); 85 85 86 87 88 86 /** IPC notification config structure. 89 87 * -
kernel/generic/include/proc/thread.h
rcf5ddf6 r5573942 244 244 extern void thread_update_accounting(void); 245 245 extern bool thread_exists(thread_t *t); 246 extern void thread_interrupt_sleep(thread_t *t);247 246 248 247 /** Fpu context slab cache. */ -
kernel/generic/include/synch/waitq.h
rcf5ddf6 r5573942 64 64 waitq_sleep_timeout((wq), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 65 65 66 struct thread; 67 66 68 extern void waitq_initialize(waitq_t *wq); 67 69 extern int waitq_sleep_timeout(waitq_t *wq, uint32_t usec, int flags); … … 71 73 extern void waitq_wakeup(waitq_t *wq, bool all); 72 74 extern void _waitq_wakeup_unsafe(waitq_t *wq, bool all); 75 extern void waitq_interrupt_sleep(struct thread *t); 73 76 74 77 #endif -
kernel/generic/src/proc/task.c
rcf5ddf6 r5573942 43 43 #include <mm/slab.h> 44 44 #include <synch/spinlock.h> 45 #include <synch/waitq.h> 45 46 #include <arch.h> 46 47 #include <panic.h> … … 364 365 365 366 if (sleeping) 366 thread_interrupt_sleep(thr);367 waitq_interrupt_sleep(thr); 367 368 } 368 369 -
kernel/generic/src/proc/thread.c
rcf5ddf6 r5573942 679 679 } 680 680 681 /** Interrupt sleeping thread.682 *683 * This routine attempts to interrupt a thread from its sleep in a waitqueue.684 * If the thread is not found sleeping, no action is taken.685 *686 * @param t Thread to be interrupted.687 */688 void thread_interrupt_sleep(thread_t *t)689 {690 waitq_t *wq;691 bool do_wakeup = false;692 ipl_t ipl;693 694 ipl = interrupts_disable();695 spinlock_lock(&threads_lock);696 if (!thread_exists(t))697 goto out;698 699 grab_locks:700 spinlock_lock(&t->lock);701 if ((wq = t->sleep_queue)) { /* assignment */702 if (!(t->sleep_interruptible)) {703 /*704 * The sleep cannot be interrupted.705 */706 spinlock_unlock(&t->lock);707 goto out;708 }709 710 if (!spinlock_trylock(&wq->lock)) {711 spinlock_unlock(&t->lock);712 goto grab_locks; /* avoid deadlock */713 }714 715 if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))716 t->timeout_pending = false;717 718 list_remove(&t->wq_link);719 t->saved_context = t->sleep_interruption_context;720 do_wakeup = true;721 t->sleep_queue = NULL;722 spinlock_unlock(&wq->lock);723 }724 spinlock_unlock(&t->lock);725 726 if (do_wakeup)727 thread_ready(t);728 729 out:730 spinlock_unlock(&threads_lock);731 interrupts_restore(ipl);732 }733 734 681 /** @} 735 682 */ -
kernel/generic/src/synch/waitq.c
rcf5ddf6 r5573942 117 117 } 118 118 119 /** Interrupt sleeping thread. 120 * 121 * This routine attempts to interrupt a thread from its sleep in a waitqueue. 122 * If the thread is not found sleeping, no action is taken. 123 * 124 * @param t Thread to be interrupted. 125 */ 126 void waitq_interrupt_sleep(thread_t *t) 127 { 128 waitq_t *wq; 129 bool do_wakeup = false; 130 ipl_t ipl; 131 132 ipl = interrupts_disable(); 133 spinlock_lock(&threads_lock); 134 if (!thread_exists(t)) 135 goto out; 136 137 grab_locks: 138 spinlock_lock(&t->lock); 139 if ((wq = t->sleep_queue)) { /* assignment */ 140 if (!(t->sleep_interruptible)) { 141 /* 142 * The sleep cannot be interrupted. 143 */ 144 spinlock_unlock(&t->lock); 145 goto out; 146 } 147 148 if (!spinlock_trylock(&wq->lock)) { 149 spinlock_unlock(&t->lock); 150 goto grab_locks; /* avoid deadlock */ 151 } 152 153 if (t->timeout_pending && timeout_unregister(&t->sleep_timeout)) 154 t->timeout_pending = false; 155 156 list_remove(&t->wq_link); 157 t->saved_context = t->sleep_interruption_context; 158 do_wakeup = true; 159 t->sleep_queue = NULL; 160 spinlock_unlock(&wq->lock); 161 } 162 spinlock_unlock(&t->lock); 163 164 if (do_wakeup) 165 thread_ready(t); 166 167 out: 168 spinlock_unlock(&threads_lock); 169 interrupts_restore(ipl); 170 } 119 171 120 172 /** Sleep until either wakeup, timeout or interruption occurs
Note:
See TracChangeset
for help on using the changeset viewer.