Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 6 → Rev 7

/SPARTAN/trunk/src/proc/thread.c
45,7 → 45,13
#include <typedefs.h>
#include <time/clock.h>
#include <list.h>
#include <config.h>
 
#ifdef __SMP__
#include <arch/interrupt.h>
#include <arch/apic.h>
#endif /* __SMP__ */
 
char *thread_states[] = {"Invalid", "Running", "Sleeping", "Ready", "Entering", "Exiting"};
 
spinlock_t threads_lock;
88,7 → 94,7
cpu_t *cpu;
runq_t *r;
pri_t pri;
int i;
int i, avg, send_ipi = 0;
 
pri = cpu_priority_high();
 
112,11 → 118,18
spinlock_unlock(&r->lock);
 
spinlock_lock(&nrdylock);
nrdy++;
avg = ++nrdy / config.cpu_active;
spinlock_unlock(&nrdylock);
 
spinlock_lock(&cpu->lock);
cpu->nrdy++;
if ((++cpu->nrdy) > avg && (config.cpu_active == config.cpu_count)) {
/*
* If there are idle halted CPU's, this will wake them up.
*/
#ifdef __SMP__
l_apic_broadcast_custom_ipi(VECTOR_WAKEUP_IPI);
#endif /* __SMP__ */
}
spinlock_unlock(&cpu->lock);
cpu_priority_restore(pri);
/SPARTAN/trunk/src/mm/tlb.c
27,9 → 27,11
*/
 
#include <mm/tlb.h>
#include <smp/ipi.h>
#include <synch/spinlock.h>
#include <typedefs.h>
#include <arch/atomic.h>
#include <arch/interrupt.h>
#include <config.h>
 
#ifdef __SMP__
59,6 → 61,11
spinlock_unlock(&tlblock);
}
 
void tlb_shootdown_ipi_send(void)
{
ipi_broadcast(VECTOR_TLB_SHOOTDOWN_IPI);
}
 
void tlb_shootdown_ipi_recv(void)
{
atomic_inc((int *) &tlb_shootdown_cnt);
/SPARTAN/trunk/arch/ia32/include/interrupt.h
58,8 → 58,9
#define VECTOR_CLK (IVT_IRQBASE+IRQ_CLK)
#define VECTOR_KBD (IVT_IRQBASE+IRQ_KBD)
 
#define VECTOR_SYSCALL (IVT_FREEBASE+0)
#define VECTOR_TLB_SHOOTDOWN (IVT_FREEBASE+1)
#define VECTOR_SYSCALL (IVT_FREEBASE+0)
#define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE+1)
#define VECTOR_WAKEUP_IPI (IVT_FREEBASE+2)
 
typedef void (* iroutine)(__u8 n, __u32 stack[]);
 
78,6 → 79,7
extern void page_fault(__u8 n, __u32 stack[]);
extern void syscall(__u8 n, __u32 stack[]);
extern void tlb_shootdown_ipi(__u8 n, __u32 stack[]);
extern void wakeup_ipi(__u8 n, __u32 stack[]);
 
extern void trap_virtual_enable_irqs(__u16 irqmask);
extern void trap_virtual_disable_irqs(__u16 irqmask);
/SPARTAN/trunk/arch/ia32/Makefile.inc
26,6 → 26,7
arch/smp/apic.c \
arch/smp/mp.c \
arch/smp/atomic.S \
arch/smp/ipi.c \
arch/ia32.c \
arch/interrupt.c \
arch/pm.c \
/SPARTAN/trunk/arch/ia32/src/ia32.c
58,7 → 58,8
trap_register(VECTOR_SYSCALL, syscall);
#ifdef __SMP__
trap_register(VECTOR_TLB_SHOOTDOWN, tlb_shootdown_ipi);
trap_register(VECTOR_TLB_SHOOTDOWN_IPI, tlb_shootdown_ipi);
trap_register(VECTOR_WAKEUP_IPI, wakeup_ipi);
#endif /* __SMP__ */
}
}
/SPARTAN/trunk/arch/ia32/src/smp/ipi.c
0,0 → 1,39
/*
* Copyright (C) 2005 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#ifdef __SMP__
 
#include <smp/ipi.h>
#include <arch/apic.h>
 
void ipi_broadcast(int ipi)
{
(void) l_apic_broadcast_custom_ipi((__u8) ipi);
}
 
#endif /* __SMP__ */
/SPARTAN/trunk/arch/ia32/src/mm/tlb.c
29,19 → 29,7
#include <mm/tlb.h>
#include <arch/asm.h>
 
#ifdef __SMP__
#include <arch/apic.h>
#include <arch/interrupt.h>
#endif /* __SMP__ */
 
void tlb_invalidate(int asid)
{
cpu_write_dba(cpu_read_dba());
}
 
#ifdef __SMP__
void tlb_shootdown_ipi_send(void)
{
(void) l_apic_broadcast_custom_ipi(VECTOR_TLB_SHOOTDOWN);
}
#endif /* __SMP__ */
/SPARTAN/trunk/arch/ia32/src/interrupt.c
100,6 → 100,11
tlb_shootdown_ipi_recv();
}
 
void wakeup_ipi(__u8 n, __u32 stack[])
{
trap_virtual_eoi();
}
 
void trap_virtual_enable_irqs(__u16 irqmask)
{
if (enable_irqs_function)