本文整理汇总了C++中curcpu函数的典型用法代码示例。如果您正苦于以下问题:C++ curcpu函数的具体用法?C++ curcpu怎么用?C++ curcpu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curcpu函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: callout_hardclock
/*
* callout_hardclock:
*
* Called from hardclock() once every tick. We schedule a soft
* interrupt if there is work to be done.
*/
void
callout_hardclock(void)
{
struct callout_cpu *cc;
int needsoftclock, ticks;
cc = curcpu()->ci_data.cpu_callout;
mutex_spin_enter(cc->cc_lock);
ticks = ++cc->cc_ticks;
MOVEBUCKET(cc, 0, ticks);
if (MASKWHEEL(0, ticks) == 0) {
MOVEBUCKET(cc, 1, ticks);
if (MASKWHEEL(1, ticks) == 0) {
MOVEBUCKET(cc, 2, ticks);
if (MASKWHEEL(2, ticks) == 0)
MOVEBUCKET(cc, 3, ticks);
}
}
needsoftclock = !CIRCQ_EMPTY(&cc->cc_todo);
mutex_spin_exit(cc->cc_lock);
if (needsoftclock)
softint_schedule(callout_sih);
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:33,代码来源:kern_timeout.c
示例2: xpq_increment_idx
static inline void
xpq_increment_idx(void)
{
if (__predict_false(++xpq_idx_array[curcpu()->ci_cpuid] == XPQUEUE_SIZE))
xpq_flush_queue();
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:7,代码来源:x86_xpmap.c
示例3: arm_dflt_setipl
void
arm_dflt_setipl(int newcpl)
{
struct cpu_info *ci = curcpu();
ci->ci_cpl = newcpl;
}
开发者ID:bradla,项目名称:OpenBSD-Hammer2,代码行数:7,代码来源:intr.c
示例4: cpu_set_curpri
void
cpu_set_curpri(int pri)
{
kpreempt_disable();
curcpu()->ci_schedstate.spc_curpriority = pri;
kpreempt_enable();
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:7,代码来源:cpu_subr.c
示例5: dosoftint
void
dosoftint()
{
struct cpu_info *ci = curcpu();
int sir, q, mask;
#ifdef MULTIPROCESSOR
register_t sr;
/* Enable interrupts */
sr = getsr();
ENABLEIPI();
__mp_lock(&kernel_lock);
#endif
while ((sir = ci->ci_softpending) != 0) {
atomic_clearbits_int(&ci->ci_softpending, sir);
for (q = SI_NQUEUES - 1; q >= 0; q--) {
mask = SINTMASK(q);
if (sir & mask)
softintr_dispatch(q);
}
}
#ifdef MULTIPROCESSOR
__mp_unlock(&kernel_lock);
setsr(sr);
#endif
}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:29,代码来源:softintr.c
示例6: db_cpu_cmd
void
db_cpu_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
{
struct cpu_info *ci;
if (!have_addr) {
cpu_debug_dump();
return;
}
if ((addr < 0) || (addr >= sparc_ncpus)) {
db_printf("%ld: CPU out of range\n", addr);
return;
}
ci = cpus[addr];
if (ci == NULL) {
db_printf("CPU %ld not configured\n", addr);
return;
}
if (ci != curcpu()) {
if (!(ci->flags & CPUFLG_PAUSED)) {
db_printf("CPU %ld not paused\n", addr);
return;
}
}
if (ci->ci_ddb_regs == 0) {
db_printf("CPU %ld has no saved regs\n", addr);
return;
}
db_printf("using CPU %ld", addr);
ddb_regp = __UNVOLATILE(ci->ci_ddb_regs);
ddb_cpuinfo = ci;
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:32,代码来源:db_interface.c
示例7: tegra_cpufreq_post
static void
tegra_cpufreq_post(void *arg1, void *arg2)
{
struct cpu_info *ci = curcpu();
ci->ci_data.cpu_cc_freq = cpufreq_get_rate() * 1000000;
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:7,代码来源:tegra_cpufreq.c
示例8: userret
static __inline void
userret (struct lwp *l, register_t pc, u_quad_t oticks)
{
struct proc *p = l->l_proc;
int sig;
/* take pending signals */
while ((sig = CURSIG(l)) != 0)
postsig(sig);
l->l_priority = l->l_usrpri;
if (want_resched) {
/*
* We're being preempted.
*/
preempt(0);
while ((sig = CURSIG(l)) != 0)
postsig(sig);
}
/*
* If profiling, charge recent system time to the trapped pc.
*/
if (l->l_flag & P_PROFIL) {
extern int psratio;
addupc_task(p, pc, (int)(p->p_sticks - oticks) * psratio);
}
curcpu()->ci_schedstate.spc_curpriority = l->l_priority;
}
开发者ID:MarginC,项目名称:kame,代码行数:31,代码来源:trap.c
示例9: mtx_enter_try
int
mtx_enter_try(struct mutex *mtx)
{
struct cpu_info *owner, *ci = curcpu();
int s;
if (mtx->mtx_wantipl != IPL_NONE)
s = splraise(mtx->mtx_wantipl);
owner = atomic_cas_ptr(&mtx->mtx_owner, NULL, ci);
#ifdef DIAGNOSTIC
if (__predict_false(owner == ci))
panic("mtx %p: locking against myself", mtx);
#endif
if (owner == NULL) {
if (mtx->mtx_wantipl != IPL_NONE)
mtx->mtx_oldipl = s;
#ifdef DIAGNOSTIC
ci->ci_mutex_level++;
#endif
membar_enter();
return (1);
}
if (mtx->mtx_wantipl != IPL_NONE)
splx(s);
return (0);
}
开发者ID:DavidAlphaFox,项目名称:openbsd-kernel,代码行数:29,代码来源:mutex.c
示例10: percpu_getref
void *
percpu_getref(percpu_t *pc)
{
kpreempt_disable();
return percpu_getptr_remote(pc, curcpu());
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:7,代码来源:subr_percpu.c
示例11: secondary_main
/*
* Further secondary CPU initialization.
*
* We are now running on our startup stack, with proper page tables.
* There is nothing to do but display some details about the CPU and its CMMUs.
*/
void
secondary_main()
{
struct cpu_info *ci = curcpu();
int s;
cpu_configuration_print(0);
ncpus++;
sched_init_cpu(ci);
nanouptime(&ci->ci_schedstate.spc_runtime);
ci->ci_curproc = NULL;
ci->ci_randseed = (arc4random() & 0x7fffffff) + 1;
/*
* Release cpu_hatch_mutex to let other secondary processors
* have a chance to run.
*/
hatch_pending_count--;
__cpu_simple_unlock(&cpu_hatch_mutex);
/* wait for cpu_boot_secondary_processors() */
__cpu_simple_lock(&cpu_boot_mutex);
__cpu_simple_unlock(&cpu_boot_mutex);
spl0();
SCHED_LOCK(s);
set_psr(get_psr() & ~PSR_IND);
SET(ci->ci_flags, CIF_ALIVE);
cpu_switchto(NULL, sched_chooseproc());
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:39,代码来源:machdep.c
示例12: wb_userret
/*
* Same as above, but also handles writeback completion on 68040.
*/
void
wb_userret(struct proc *p, struct frame *fp)
{
int sig;
union sigval sv;
/* take pending signals */
while ((sig = CURSIG(p)) != 0)
postsig(sig);
p->p_priority = p->p_usrpri;
/*
* Deal with user mode writebacks (from trap, or from sigreturn).
* If any writeback fails, go back and attempt signal delivery
* unless we have already been here and attempted the writeback
* (e.g. bad address with user ignoring SIGSEGV). In that case,
* we just return to the user without successfully completing
* the writebacks. Maybe we should just drop the sucker?
*/
if (mmutype == MMU_68040 && fp->f_format == FMT7) {
if ((sig = writeback(fp)) != 0) {
sv.sival_ptr = (void *)fp->f_fmt7.f_fa;
trapsignal(p, sig, T_MMUFLT, SEGV_MAPERR, sv);
while ((sig = CURSIG(p)) != 0)
postsig(sig);
p->p_priority = p->p_usrpri;
}
}
curcpu()->ci_schedstate.spc_curpriority = p->p_priority;
}
开发者ID:grange,项目名称:openbsd-kernel,代码行数:34,代码来源:trap.c
示例13: cpu_intr
void
cpu_intr(int ppl, vaddr_t pc, uint32_t status)
{
struct cpu_info * const ci = curcpu();
uint32_t pending;
int ipl;
#ifdef DIAGNOSTIC
const int mtx_count = ci->ci_mtx_count;
const u_int biglock_count = ci->ci_biglock_count;
const u_int blcnt = curlwp->l_blcnt;
#endif
KASSERT(ci->ci_cpl == IPL_HIGH);
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
ci->ci_data.cpu_nintr++;
while (ppl < (ipl = splintr(&pending))) {
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
splx(ipl); /* lower to interrupt level */
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
KASSERTMSG(ci->ci_cpl == ipl,
"%s: cpl (%d) != ipl (%d)", __func__, ci->ci_cpl, ipl);
KASSERT(pending != 0);
cf.pc = pc;
cf.sr = status;
cf.intr = (ci->ci_idepth > 1);
#ifdef MIPS3_ENABLE_CLOCK_INTR
if (pending & MIPS_INT_MASK_5) {
KASSERTMSG(ipl == IPL_SCHED,
"%s: ipl (%d) != IPL_SCHED (%d)",
__func__, ipl, IPL_SCHED);
/* call the common MIPS3 clock interrupt handler */
mips3_clockintr(&cf);
pending ^= MIPS_INT_MASK_5;
}
#endif
if (pending != 0) {
/* Process I/O and error interrupts. */
evbmips_iointr(ipl, pc, pending);
}
KASSERT(biglock_count == ci->ci_biglock_count);
KASSERT(blcnt == curlwp->l_blcnt);
KASSERT(mtx_count == ci->ci_mtx_count);
/*
* If even our spl is higher now (due to interrupting while
* spin-lock is held and higher IPL spin-lock is locked, it
* can no longer be locked so it's safe to lower IPL back
* to ppl.
*/
(void) splhigh(); /* disable interrupts */
}
KASSERT(ci->ci_cpl == IPL_HIGH);
KDASSERT(mips_cp0_status_read() & MIPS_SR_INT_IE);
}
开发者ID:goroutines,项目名称:rumprun,代码行数:60,代码来源:interrupt.c
示例14: amlogic_cpufreq_cb
static void
amlogic_cpufreq_cb(void *arg1, void *arg2)
{
struct cpu_info *ci = curcpu();
ci->ci_data.cpu_cc_freq = cpufreq_get_rate() * 1000000;
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:7,代码来源:amlogic_cpufreq.c
示例15: cpu_idle_mwait_cycle
void
cpu_idle_mwait_cycle(void)
{
struct cpu_info *ci = curcpu();
if ((read_rflags() & PSL_I) == 0)
panic("idle with interrupts blocked!");
/* something already queued? */
if (!cpu_is_idle(ci))
return;
/*
* About to idle; setting the MWAIT_IN_IDLE bit tells
* cpu_unidle() that it can't be a no-op and tells cpu_kick()
* that it doesn't need to use an IPI. We also set the
* MWAIT_KEEP_IDLING bit: those routines clear it to stop
* the mwait. Once they're set, we do a final check of the
* queue, in case another cpu called setrunqueue() and added
* something to the queue and called cpu_unidle() between
* the check in sched_idle() and here.
*/
atomic_setbits_int(&ci->ci_mwait, MWAIT_IDLING | MWAIT_ONLY);
if (cpu_is_idle(ci)) {
monitor(&ci->ci_mwait, 0, 0);
if ((ci->ci_mwait & MWAIT_IDLING) == MWAIT_IDLING)
mwait(0, 0);
}
/* done idling; let cpu_kick() know that an IPI is required */
atomic_clearbits_int(&ci->ci_mwait, MWAIT_IDLING);
}
开发者ID:mosconi,项目名称:openbsd,代码行数:32,代码来源:cpu.c
示例16: __mp_lock
void
__mp_lock(struct __mp_lock *mpl)
{
int s;
struct cpu_info *ci = curcpu();
/*
* Please notice that mpl_count gets incremented twice for the
* first lock. This is on purpose. The way we release the lock
* in mp_unlock is to decrement the mpl_count and then check if
* the lock should be released. Since mpl_count is what we're
* spinning on, decrementing it in mpl_unlock to 0 means that
* we can't clear mpl_cpu, because we're no longer holding the
* lock. In theory mpl_cpu doesn't need to be cleared, but it's
* safer to clear it and besides, setting mpl_count to 2 on the
* first lock makes most of this code much simpler.
*/
while (1) {
s = splhigh();
if (__cpu_cas(&mpl->mpl_count, 0, 1) == 0) {
alpha_mb();
mpl->mpl_cpu = ci;
}
if (mpl->mpl_cpu == ci) {
mpl->mpl_count++;
splx(s);
break;
}
splx(s);
__mp_lock_spin(mpl);
}
}
开发者ID:bradla,项目名称:OpenBSD-Hammer2,代码行数:34,代码来源:lock_machdep.c
示例17: cal_timer
static void
cal_timer(void)
{
uint32_t cntfreq;
cntfreq = curcpu()->ci_cpu_freq = RA_CLOCK_RATE;
/* MIPS 4Kc CP0 counts every other clock */
if (mips_options.mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT)
cntfreq /= 2;
curcpu()->ci_cycles_per_hz = (cntfreq + hz / 2) / hz;
/* Compute number of cycles per 1us (1/MHz). 0.5MHz is for roundup. */
curcpu()->ci_divisor_delay = ((cntfreq + 500000) / 1000000);
}
开发者ID:yazshel,项目名称:netbsd-kernel,代码行数:16,代码来源:machdep.c
示例18: cpuwatch_set
/*
* cpuwatch_set - establish a MIPS COP0 watchpoint
*/
void
cpuwatch_set(cpu_watchpoint_t *cwp)
{
struct cpu_info * const ci = curcpu();
uint32_t watchhi;
register_t watchlo;
int cwnum = cwp - &ci->ci_cpuwatch_tab[0];
KASSERT(cwp >= &ci->ci_cpuwatch_tab[0] &&
cwp <= &ci->ci_cpuwatch_tab[ci->ci_cpuwatch_count-1]);
watchlo = cwp->cw_addr;
if (cwp->cw_mode & CPUWATCH_WRITE)
watchlo |= __BIT(0);
if (cwp->cw_mode & CPUWATCH_READ)
watchlo |= __BIT(1);
if (cwp->cw_mode & CPUWATCH_EXEC)
watchlo |= __BIT(2);
if (cwp->cw_mode & CPUWATCH_ASID)
watchhi = cwp->cw_asid << 16; /* addr qualified by asid */
else
watchhi = __BIT(30); /* addr not qual. by asid (Global) */
if (cwp->cw_mode & CPUWATCH_MASK)
watchhi |= cwp->cw_mask; /* set "dont care" addr match bits */
mipsNN_cp0_watchhi_write(cwnum, watchhi);
mipsNN_cp0_watchlo_write(cwnum, watchlo);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:32,代码来源:cpu_subr.c
示例19: m197_soft_ipi
/*
* Maskable IPIs.
*
* These IPIs are received as non maskable, but are not processed in
* the NMI handler; instead, they are processed from the soft interrupt
* handler.
*
* XXX This is grossly suboptimal.
*/
void
m197_soft_ipi()
{
struct cpu_info *ci = curcpu();
struct trapframe faketf;
int s;
__mp_lock(&kernel_lock);
s = splclock();
if (ci->ci_h_sxip != 0) {
faketf.tf_cpu = ci;
faketf.tf_sxip = ci->ci_h_sxip;
faketf.tf_epsr = ci->ci_h_epsr;
ci->ci_h_sxip = 0;
hardclock((struct clockframe *)&faketf);
}
if (ci->ci_s_sxip != 0) {
faketf.tf_cpu = ci;
faketf.tf_sxip = ci->ci_s_sxip;
faketf.tf_epsr = ci->ci_s_epsr;
ci->ci_s_sxip = 0;
statclock((struct clockframe *)&faketf);
}
splx(s);
__mp_unlock(&kernel_lock);
}
开发者ID:enukane,项目名称:openbsd-work,代码行数:38,代码来源:m197_machdep.c
示例20: cpu_pause
/*
* Pause this cpu
*/
void
cpu_pause(struct reg *regsp)
{
int s = splhigh();
cpuid_t cii = cpu_index(curcpu());
if (__predict_false(cold))
return;
do {
kcpuset_atomic_set(cpus_paused, cii);
do {
;
} while (kcpuset_isset(cpus_paused, cii));
kcpuset_atomic_set(cpus_resumed, cii);
#if defined(DDB)
if (ddb_running_on_this_cpu_p())
cpu_Debugger();
if (ddb_running_on_any_cpu_p())
continue;
#endif
} while (false);
splx(s);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:28,代码来源:cpu_subr.c
注:本文中的curcpu函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论