Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2088 → Rev 2089

/trunk/kernel/generic/src/synch/rwlock.c
63,7 → 63,6
#include <synch/waitq.h>
#include <synch/synch.h>
#include <adt/list.h>
#include <typedefs.h>
#include <arch/asm.h>
#include <arch.h>
#include <proc/thread.h>
/trunk/kernel/generic/src/synch/waitq.c
49,7 → 49,6
#include <proc/scheduler.h>
#include <arch/asm.h>
#include <arch/types.h>
#include <typedefs.h>
#include <time/timeout.h>
#include <arch.h>
#include <context.h>
117,59 → 116,7
spinlock_unlock(&threads_lock);
}
 
/** Interrupt sleeping thread.
*
* This routine attempts to interrupt a thread from its sleep in a waitqueue.
* If the thread is not found sleeping, no action is taken.
*
* @param t Thread to be interrupted.
*/
void waitq_interrupt_sleep(thread_t *t)
{
waitq_t *wq;
bool do_wakeup = false;
ipl_t ipl;
 
ipl = interrupts_disable();
spinlock_lock(&threads_lock);
if (!thread_exists(t))
goto out;
 
grab_locks:
spinlock_lock(&t->lock);
if ((wq = t->sleep_queue)) { /* assignment */
if (!(t->sleep_interruptible)) {
/*
* The sleep cannot be interrupted.
*/
spinlock_unlock(&t->lock);
goto out;
}
if (!spinlock_trylock(&wq->lock)) {
spinlock_unlock(&t->lock);
goto grab_locks; /* avoid deadlock */
}
 
if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
t->timeout_pending = false;
 
list_remove(&t->wq_link);
t->saved_context = t->sleep_interruption_context;
do_wakeup = true;
t->sleep_queue = NULL;
spinlock_unlock(&wq->lock);
}
spinlock_unlock(&t->lock);
 
if (do_wakeup)
thread_ready(t);
 
out:
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
}
 
/** Sleep until either wakeup, timeout or interruption occurs
*
* This is a sleep implementation which allows itself to time out or to be
425,7 → 372,7
* This is not necessary because of mutual exclusion
* (the link belongs to the wait queue), but because
* of synchronization with waitq_timeouted_sleep()
* and waitq_interrupt_sleep().
* and thread_interrupt_sleep().
*
* In order for these two functions to work, the following
* invariant must hold:
/trunk/kernel/generic/src/synch/condvar.c
40,7 → 40,6
#include <synch/waitq.h>
#include <synch/synch.h>
#include <arch.h>
#include <typedefs.h>
 
/** Initialize condition variable.
*
/trunk/kernel/generic/src/main/kinit.c
62,6 → 62,7
#include <console/kconsole.h>
#include <security/cap.h>
#include <lib/rd.h>
#include <ipc/ipc.h>
 
#ifdef CONFIG_SMP
#include <smp/smp.h>
/trunk/kernel/generic/src/main/main.c
53,6 → 53,7
#include <debug.h>
#include <config.h>
#include <time/clock.h>
#include <time/timeout.h>
#include <proc/scheduler.h>
#include <proc/thread.h>
#include <proc/task.h>
74,7 → 75,6
#include <arch/arch.h>
#include <arch.h>
#include <arch/faddr.h>
#include <typedefs.h>
#include <ipc/ipc.h>
#include <macros.h>
#include <adt/btree.h>
/trunk/kernel/generic/src/debug/symtab.c
36,7 → 36,6
*/
 
#include <symtab.h>
#include <typedefs.h>
#include <arch/byteorder.h>
#include <func.h>
#include <print.h>
/trunk/kernel/generic/src/cpu/cpu.c
44,7 → 44,6
#include <arch/types.h>
#include <config.h>
#include <panic.h>
#include <typedefs.h>
#include <memstr.h>
#include <adt/list.h>
#include <print.h>
/trunk/kernel/generic/src/time/timeout.c
36,7 → 36,6
*/
 
#include <time/timeout.h>
#include <typedefs.h>
#include <arch/types.h>
#include <config.h>
#include <panic.h>
/trunk/kernel/generic/src/ddi/device.c
38,7 → 38,6
#include <ddi/device.h>
#include <atomic.h>
#include <debug.h>
#include <typedefs.h>
 
static atomic_t last;
 
/trunk/kernel/generic/src/ddi/irq.c
69,7 → 69,6
#include <ddi/irq.h>
#include <adt/hash_table.h>
#include <arch/types.h>
#include <typedefs.h>
#include <synch/spinlock.h>
#include <arch.h>
 
/trunk/kernel/generic/src/console/console.c
38,7 → 38,6
#include <synch/waitq.h>
#include <synch/spinlock.h>
#include <arch/types.h>
#include <typedefs.h>
#include <arch.h>
#include <func.h>
#include <print.h>
/trunk/kernel/generic/src/console/cmd.c
45,7 → 45,6
#include <console/kconsole.h>
#include <print.h>
#include <panic.h>
#include <typedefs.h>
#include <arch/types.h>
#include <adt/list.h>
#include <arch.h>
/trunk/kernel/generic/src/console/kconsole.c
43,7 → 43,6
#include <console/cmd.h>
#include <print.h>
#include <panic.h>
#include <typedefs.h>
#include <arch/types.h>
#include <adt/list.h>
#include <arch.h>
/trunk/kernel/generic/src/proc/scheduler.c
44,6 → 44,7
#include <mm/frame.h>
#include <mm/page.h>
#include <mm/as.h>
#include <time/timeout.h>
#include <time/delay.h>
#include <arch/asm.h>
#include <arch/faddr.h>
52,11 → 53,11
#include <synch/spinlock.h>
#include <config.h>
#include <context.h>
#include <fpu_context.h>
#include <func.h>
#include <arch.h>
#include <adt/list.h>
#include <panic.h>
#include <typedefs.h>
#include <cpu.h>
#include <print.h>
#include <debug.h>
/trunk/kernel/generic/src/proc/the.c
42,7 → 42,6
*/
 
#include <arch.h>
#include <typedefs.h>
 
 
/** Initialize THE structure
/trunk/kernel/generic/src/proc/task.c
363,7 → 363,7
spinlock_unlock(&thr->lock);
if (sleeping)
waitq_interrupt_sleep(thr);
thread_interrupt_sleep(thr);
}
spinlock_unlock(&ta->lock);
/trunk/kernel/generic/src/proc/thread.c
53,8 → 53,8
#include <context.h>
#include <adt/btree.h>
#include <adt/list.h>
#include <typedefs.h>
#include <time/clock.h>
#include <time/timeout.h>
#include <config.h>
#include <arch/interrupt.h>
#include <smp/ipi.h>
678,6 → 678,59
return 0;
}
 
/** Interrupt sleeping thread.
*
* This routine attempts to interrupt a thread from its sleep in a waitqueue.
* If the thread is not found sleeping, no action is taken.
*
* @param t Thread to be interrupted.
*/
void thread_interrupt_sleep(thread_t *t)
{
waitq_t *wq;
bool do_wakeup = false;
ipl_t ipl;
 
ipl = interrupts_disable();
spinlock_lock(&threads_lock);
if (!thread_exists(t))
goto out;
 
grab_locks:
spinlock_lock(&t->lock);
if ((wq = t->sleep_queue)) { /* assignment */
if (!(t->sleep_interruptible)) {
/*
* The sleep cannot be interrupted.
*/
spinlock_unlock(&t->lock);
goto out;
}
if (!spinlock_trylock(&wq->lock)) {
spinlock_unlock(&t->lock);
goto grab_locks; /* avoid deadlock */
}
 
if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
t->timeout_pending = false;
 
list_remove(&t->wq_link);
t->saved_context = t->sleep_interruption_context;
do_wakeup = true;
t->sleep_queue = NULL;
spinlock_unlock(&wq->lock);
}
spinlock_unlock(&t->lock);
 
if (do_wakeup)
thread_ready(t);
 
out:
spinlock_unlock(&threads_lock);
interrupts_restore(ipl);
}
 
/** @}
*/
 
/trunk/kernel/generic/src/lib/elf.c
39,7 → 39,6
#include <lib/elf.h>
#include <debug.h>
#include <arch/types.h>
#include <typedefs.h>
#include <mm/as.h>
#include <mm/frame.h>
#include <mm/slab.h>
/trunk/kernel/generic/src/lib/func.c
40,7 → 40,6
#include <cpu.h>
#include <arch/asm.h>
#include <arch.h>
#include <typedefs.h>
#include <console/kconsole.h>
 
atomic_t haltstate = {0}; /**< Halt flag */
/trunk/kernel/generic/src/security/cap.c
43,7 → 43,6
#include <syscall/sysarg64.h>
#include <syscall/copy.h>
#include <arch.h>
#include <typedefs.h>
#include <errno.h>
 
/** Set capabilities.
/trunk/kernel/generic/src/adt/btree.c
51,7 → 51,6
#include <mm/slab.h>
#include <debug.h>
#include <panic.h>
#include <typedefs.h>
#include <print.h>
 
static void btree_destroy_subtree(btree_node_t *root);
/trunk/kernel/generic/src/adt/hash_table.c
39,7 → 39,6
 
#include <adt/hash_table.h>
#include <adt/list.h>
#include <typedefs.h>
#include <arch/types.h>
#include <debug.h>
#include <mm/slab.h>
/trunk/kernel/generic/src/adt/bitmap.c
38,7 → 38,6
*/
 
#include <adt/bitmap.h>
#include <typedefs.h>
#include <arch/types.h>
#include <align.h>
#include <debug.h>
/trunk/kernel/generic/src/mm/tlb.c
44,7 → 44,6
#include <arch/mm/tlb.h>
#include <smp/ipi.h>
#include <synch/spinlock.h>
#include <typedefs.h>
#include <atomic.h>
#include <arch/interrupt.h>
#include <config.h>
51,6 → 50,7
#include <arch.h>
#include <panic.h>
#include <debug.h>
#include <cpu.h>
 
/**
* This lock is used for synchronisation between sender and
/trunk/kernel/generic/src/mm/backend_anon.c
47,7 → 47,6
#include <adt/btree.h>
#include <errno.h>
#include <arch/types.h>
#include <typedefs.h>
#include <align.h>
#include <arch.h>
 
/trunk/kernel/generic/src/mm/as.c
74,7 → 74,6
#include <config.h>
#include <align.h>
#include <arch/types.h>
#include <typedefs.h>
#include <syscall/copy.h>
#include <arch/interrupt.h>
 
168,7 → 167,11
as->refcount = 0;
as->cpu_refcount = 0;
#ifdef AS_PAGE_TABLE
as->page_table = page_table_create(flags);
#else
page_table_create(flags);
#endif
 
return as;
}
216,7 → 219,11
}
 
btree_destroy(&as->as_area_btree);
#ifdef AS_PAGE_TABLE
page_table_destroy(as->page_table);
#else
page_table_destroy(NULL);
#endif
 
interrupts_restore(ipl);
/trunk/kernel/generic/src/mm/buddy.c
42,8 → 42,6
#include <mm/buddy.h>
#include <mm/frame.h>
#include <arch/types.h>
#include <typedefs.h>
#include <adt/list.h>
#include <debug.h>
#include <print.h>
 
/trunk/kernel/generic/src/mm/backend_phys.c
37,7 → 37,6
 
#include <debug.h>
#include <arch/types.h>
#include <typedefs.h>
#include <mm/as.h>
#include <mm/frame.h>
#include <mm/slab.h>
/trunk/kernel/generic/src/mm/frame.c
51,7 → 51,6
*
*/
 
#include <typedefs.h>
#include <arch/types.h>
#include <mm/frame.h>
#include <mm/as.h>
/trunk/kernel/generic/src/mm/page.c
46,7 → 46,6
#include <mm/as.h>
#include <mm/frame.h>
#include <arch/types.h>
#include <typedefs.h>
#include <arch/asm.h>
#include <memstr.h>
#include <debug.h>
/trunk/kernel/generic/src/mm/backend_elf.c
38,7 → 38,6
#include <lib/elf.h>
#include <debug.h>
#include <arch/types.h>
#include <typedefs.h>
#include <mm/as.h>
#include <mm/frame.h>
#include <mm/slab.h>
/trunk/kernel/generic/src/syscall/copy.c
44,7 → 44,6
#include <macros.h>
#include <arch.h>
#include <errno.h>
#include <typedefs.h>
 
/** Copy data from userspace to kernel.
*