您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ spin_trylock函数代码示例

51自学网 2021-06-03 08:10:19
  C++
这篇教程C++ spin_trylock函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中spin_trylock函数的典型用法代码示例。如果您正苦于以下问题:C++ spin_trylock函数的具体用法?C++ spin_trylock怎么用?C++ spin_trylock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了spin_trylock函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: x86_backtrace

voidx86_backtrace(struct pt_regs * const regs, unsigned int depth){	struct frame_head *head;#ifdef CONFIG_X86_64	head = (struct frame_head *)regs->rbp;#else	head = (struct frame_head *)regs->ebp;#endif	if (!user_mode_vm(regs)) {		while (depth-- && valid_kernel_stack(head, regs))			head = dump_backtrace(head);		return;	}#ifdef CONFIG_SMP	if (!spin_trylock(&current->mm->page_table_lock))		return;#endif	while (depth-- && head && pages_present(head))		head = dump_backtrace(head);#ifdef CONFIG_SMP	spin_unlock(&current->mm->page_table_lock);#endif}
开发者ID:camelguo,项目名称:linux-2.6-trimedia,代码行数:29,


示例2: serial_hsu_console_write

/* * Print a string to the serial port trying not to disturb * any possible real use of the port... * *	The console_lock must be held when we get here. */static voidserial_hsu_console_write(struct console *co, const char *s, unsigned int count){	struct uart_hsu_port *up = serial_hsu_ports[co->index];	unsigned long flags;	unsigned int ier;	int locked = 1;	local_irq_save(flags);	if (up->port.sysrq)		locked = 0;	else if (oops_in_progress) {		locked = spin_trylock(&up->port.lock);	} else		spin_lock(&up->port.lock);	/* First save the IER then disable the interrupts */	ier = serial_in(up, UART_IER);	serial_out(up, UART_IER, 0);	uart_console_write(&up->port, s, count, serial_hsu_console_putchar);	/*	 * Finally, wait for transmitter to become empty	 * and restore the IER	 */	wait_for_xmitr(up);	serial_out(up, UART_IER, ier);	if (locked)		spin_unlock(&up->port.lock);	local_irq_restore(flags);}
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:39,


示例3: serial_tx_interrupt

void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs){    int i, n;    unsigned long flags;    local_irq_save(flags);    /*     * Avoid spinning for a long time: if there is a long-term lock holder     * then we know that they'll be stuffing bytes into the transmitter which     * will therefore not be empty for long.     */    while ( !spin_trylock(&port->tx_lock) )    {        if ( port->driver->tx_ready(port) <= 0 )            goto out;        cpu_relax();    }    for ( i = 0, n = port->driver->tx_ready(port); i < n; i++ )    {        if ( port->txbufc == port->txbufp )            break;        port->driver->putc(            port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);    }    if ( i && port->driver->flush )        port->driver->flush(port);    spin_unlock(&port->tx_lock); out:    local_irq_restore(flags);}
开发者ID:HPSI,项目名称:xen-v4v,代码行数:34,


示例4: set_a_bus_req

static ssize_tset_a_bus_req(struct device *dev, struct device_attribute *attr,	      const char *buf, size_t count){	struct mv_otg *mvotg = dev_get_drvdata(dev);	if (count > 2)		return -1;	/* We will use this interface to change to A device */	if (mvotg->phy.state != OTG_STATE_B_IDLE	    && mvotg->phy.state != OTG_STATE_A_IDLE)		return -1;	/* The clock may disabled and we need to set irq for ID detected */	mv_otg_enable(mvotg);	mv_otg_init_irq(mvotg);	if (buf[0] == '1') {		mvotg->otg_ctrl.a_bus_req = 1;		mvotg->otg_ctrl.a_bus_drop = 0;		dev_dbg(&mvotg->pdev->dev,			"User request: a_bus_req = 1/n");		if (spin_trylock(&mvotg->wq_lock)) {			mv_otg_run_state_machine(mvotg, 0);			spin_unlock(&mvotg->wq_lock);		}	}	return count;}
开发者ID:AiWinters,项目名称:linux,代码行数:32,


示例5: softuart_downcall

/* * This is called when the HV needs to signal that receive data is * available to read or that transmit buffer space has become * available. */static void softuart_downcall(struct hv_driver_cb *cb, __hv32 reason){	unsigned long flags;	local_irq_save(flags);	if (spin_trylock(&softuart_callback_lock)) {		struct softuart_private *softuartp =			(struct softuart_private *)cb->dev;		struct tty_struct *tty = softuartp->tty;		if (tty) {			if (reason == SOFTUART_CLIENTINT_RX) {				/*				 * Some data has been received by the				 * HV driver and is ready to read.				 */				softuart_do_receive_chars(tty);			} else if (reason == SOFTUART_CLIENTINT_WRITEROOM) {				/*				 * If the output buffer had filled up then the				 * tty has been put to sleep.  The HV has				 * indicated that there's buffer space				 * available, so we wake the tty up.				 */				if (waitqueue_active(&tty->write_wait) &&				    softuart_write_room(tty))					tty_wakeup(tty);			}		}		spin_unlock(&softuart_callback_lock);	}	local_irq_restore(flags);}
开发者ID:rslotte,项目名称:OGS-Tile,代码行数:37,


示例6: set_a_bus_drop

static ssize_tset_a_bus_drop(struct device *dev, struct device_attribute *attr,	       const char *buf, size_t count){	struct mv_otg *mvotg = dev_get_drvdata(dev);	if (!mvotg->phy.otg->default_a)		return -1;	if (count > 2)		return -1;	if (buf[0] == '0') {		mvotg->otg_ctrl.a_bus_drop = 0;		dev_dbg(&mvotg->pdev->dev,			"User request: a_bus_drop = 0/n");	} else if (buf[0] == '1') {		mvotg->otg_ctrl.a_bus_drop = 1;		mvotg->otg_ctrl.a_bus_req = 0;		dev_dbg(&mvotg->pdev->dev,			"User request: a_bus_drop = 1/n");		dev_dbg(&mvotg->pdev->dev,			"User request: and a_bus_req = 0/n");	}	if (spin_trylock(&mvotg->wq_lock)) {		mv_otg_run_state_machine(mvotg, 0);		spin_unlock(&mvotg->wq_lock);	}	return count;}
开发者ID:AiWinters,项目名称:linux,代码行数:31,


示例7: spinLock_write

static ssize_t spinLock_write(struct file *file, const char __user *buf,		size_t count, loff_t *ppos){//	char *cmd = (char *) malloc(sizeof(char *));	char cmd[10] = { 0 };	if (copy_from_user(cmd, (void*) buf, count))	{		return -EINVAL;	}	else	{		if (strcmp("lock/n", cmd) == 0)		{			spin_lock(&lock);			mdelay(10000);			spin_unlock(&lock);		}		else if (strcmp("trylock/n", cmd) == 0)		{			if (spin_trylock(&lock))			{				printk("spin_lock is available/n");				spin_unlock(&lock);			}			else			{				printk("spin_lock is busy/n");				return -EBUSY;			}		}		return count;	}}
开发者ID:hust-MC,项目名称:Spin_Lock,代码行数:33,


示例8: mce_spin_lock

static void mce_spin_lock(spinlock_t *lk){      while (!spin_trylock(lk)) {              cpu_relax();              mce_panic_check();      }}
开发者ID:sheep,项目名称:xen,代码行数:7,


示例9: t1_espi_get_mon_t204

/* * This function is for T204 only. * compare with t1_espi_get_mon(), it reads espiInTxSop[0 ~ 3] in * one shot, since there is no per port counter on the out side. */int t1_espi_get_mon_t204(adapter_t *adapter, u32 *valp, u8 wait){	struct peespi *espi = adapter->espi;	u8 i, nport = (u8)adapter->params.nports;	if (!wait) {		if (!spin_trylock(&espi->lock))			return -1;	} else		spin_lock(&espi->lock);	if ((espi->misc_ctrl & MON_MASK) != F_MONITORED_DIRECTION) {		espi->misc_ctrl = (espi->misc_ctrl & ~MON_MASK) |					F_MONITORED_DIRECTION;		writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);	}	for (i = 0 ; i < nport; i++, valp++) {		if (i) {			writel(espi->misc_ctrl | V_MONITORED_PORT_NUM(i),			       adapter->regs + A_ESPI_MISC_CONTROL);		}		*valp = readl(adapter->regs + A_ESPI_SCH_TOKEN3);	}	writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);	spin_unlock(&espi->lock);	return 0;}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:33,


示例10: t1_espi_get_mon

u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait){	struct peespi *espi = adapter->espi;	u32 sel;	if (!is_T2(adapter))		return 0;	sel = V_MONITORED_PORT_NUM((addr & 0x3c) >> 2);	if (!wait) {		if (!spin_trylock(&espi->lock))			return 0;	} else		spin_lock(&espi->lock);	if ((sel != (espi->misc_ctrl & MON_MASK))) {		writel(((espi->misc_ctrl & ~MON_MASK) | sel),		       adapter->regs + A_ESPI_MISC_CONTROL);		sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3);		writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);	} else		sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3);	spin_unlock(&espi->lock);	return sel;}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:25,


示例11: autofs4_sbi

/* * Calculate and dget next entry in top down tree traversal. */static struct dentry *get_next_positive_dentry(struct dentry *prev,					       struct dentry *root){	struct autofs_sb_info *sbi = autofs4_sbi(root->d_sb);	struct list_head *next;	struct dentry *p, *ret;	if (prev == NULL)		return dget(root);	spin_lock(&sbi->lookup_lock);relock:	p = prev;	spin_lock(&p->d_lock);again:	next = p->d_subdirs.next;	if (next == &p->d_subdirs) {		while (1) {			struct dentry *parent;			if (p == root) {				spin_unlock(&p->d_lock);				spin_unlock(&sbi->lookup_lock);				dput(prev);				return NULL;			}			parent = p->d_parent;			if (!spin_trylock(&parent->d_lock)) {				spin_unlock(&p->d_lock);				cpu_relax();				goto relock;			}			spin_unlock(&p->d_lock);			next = p->d_child.next;			p = parent;			if (next != &parent->d_subdirs)				break;		}	}	ret = list_entry(next, struct dentry, d_child);	spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED);	/* Negative dentry - try next */	if (!simple_positive(ret)) {		spin_unlock(&p->d_lock);		lock_set_subclass(&ret->d_lock.dep_map, 0, _RET_IP_);		p = ret;		goto again;	}	dget_dlock(ret);	spin_unlock(&ret->d_lock);	spin_unlock(&p->d_lock);	spin_unlock(&sbi->lookup_lock);	dput(prev);	return ret;}
开发者ID:acton393,项目名称:linux,代码行数:62,


示例12: pstore_dump

/* * callback from kmsg_dump. (s2,l2) has the most recently * written bytes, older bytes are in (s1,l1). Save as much * as we can from the end of the buffer. */static void pstore_dump(struct kmsg_dumper *dumper,	    enum kmsg_dump_reason reason,	    const char *s1, unsigned long l1,	    const char *s2, unsigned long l2){	unsigned long	s1_start, s2_start;	unsigned long	l1_cpy, l2_cpy;	unsigned long	size, total = 0;	char		*dst;	const char	*why;	u64		id;	int		hsize, ret;	unsigned int	part = 1;	unsigned long	flags = 0;	int		is_locked = 0;	why = get_reason_str(reason);	if (in_nmi()) {		is_locked = spin_trylock(&psinfo->buf_lock);		if (!is_locked)			pr_err("pstore dump routine blocked in NMI, may corrupt error record/n");	} else		spin_lock_irqsave(&psinfo->buf_lock, flags);	oopscount++;	while (total < kmsg_bytes) {		dst = psinfo->buf;		hsize = sprintf(dst, "%s#%d Part%d/n", why, oopscount, part);		size = psinfo->bufsize - hsize;		dst += hsize;		l2_cpy = min(l2, size);		l1_cpy = min(l1, size - l2_cpy);		if (l1_cpy + l2_cpy == 0)			break;		s2_start = l2 - l2_cpy;		s1_start = l1 - l1_cpy;		memcpy(dst, s1 + s1_start, l1_cpy);		memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);		ret = psinfo->write(PSTORE_TYPE_DMESG, reason, &id, part,				    oopscount, hsize + l1_cpy + l2_cpy, psinfo);		if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted())			pstore_new_entry = 1;		l1 -= l1_cpy;		l2 -= l2_cpy;		total += l1_cpy + l2_cpy;		part++;	}	if (in_nmi()) {		if (is_locked)			spin_unlock(&psinfo->buf_lock);	} else		spin_unlock_irqrestore(&psinfo->buf_lock, flags);}
开发者ID:3null,项目名称:fastsocket,代码行数:63,


示例13: process_hvlpevents

void process_hvlpevents(void){	struct HvLpEvent * event; restart:	/* If we have recursed, just return */	if (!spin_trylock(&hvlpevent_queue.hq_lock))		return;	for (;;) {		event = get_next_hvlpevent();		if (event) {			/* Call appropriate handler here, passing			 * a pointer to the LpEvent.  The handler			 * must make a copy of the LpEvent if it			 * needs it in a bottom half. (perhaps for			 * an ACK)			 *			 *  Handlers are responsible for ACK processing			 *			 * The Hypervisor guarantees that LpEvents will			 * only be delivered with types that we have			 * registered for, so no type check is necessary			 * here!			 */			if (event->xType < HvLpEvent_Type_NumTypes)				__get_cpu_var(hvlpevent_counts)[event->xType]++;			if (event->xType < HvLpEvent_Type_NumTypes &&					lpEventHandler[event->xType])				lpEventHandler[event->xType](event);			else {				u8 type = event->xType;				/*				 * Don't printk in the spinlock as printk				 * may require ack events form the HV to send				 * any characters there.				 */				hvlpevent_clear_valid(event);				spin_unlock(&hvlpevent_queue.hq_lock);				printk(KERN_INFO					"Unexpected Lp Event type=%d/n", type);				goto restart;			}			hvlpevent_clear_valid(event);		} else if (hvlpevent_queue.hq_overflow_pending)			/*			 * No more valid events. If overflow events are			 * pending process them			 */			HvCallEvent_getOverflowLpEvents(hvlpevent_queue.hq_index);		else			break;	}	spin_unlock(&hvlpevent_queue.hq_lock);}
开发者ID:ForayJones,项目名称:iods,代码行数:58,


示例14: srecorder_unregister_external_log

/**    @function: int srecorder_unregister_external_log(unsigned id)    @brief:     @param:     @return:     @note:**/int srecorder_unregister_external_log(unsigned id){    log_registration_entry_t* prev_entry = NULL;    log_registration_entry_t* curr_entry = NULL;    if (spin_trylock(&srecorder_registration_lock) == 0)    {        return -1;    }    if (spin_trylock(&srecorder_list_lock) == 0)    {        goto reg_out;    }    curr_entry = p_log_registration_list;    while (curr_entry != NULL)    {        if (curr_entry->info.log_id == id)        {            if (curr_entry == p_log_registration_list)            {                p_log_registration_list =  curr_entry->next;            }            else            {                prev_entry->next = curr_entry->next;            }            spin_unlock(&srecorder_list_lock);            spin_unlock(&srecorder_registration_lock);            kfree(curr_entry);            return 0;        }        prev_entry = curr_entry;        curr_entry = curr_entry->next;    }    /* return if nothing found in loop */    spin_unlock(&srecorder_list_lock);reg_out:    spin_unlock(&srecorder_registration_lock);    return -1;}
开发者ID:Nothing-Dev,项目名称:android_kernel_huawei_hwY635,代码行数:52,


示例15: smp_make_wrapper

handler_wrapper_t*smp_make_wrapper(){	int i;	for(i = 0; i < sizeof(wrapper_pool)/sizeof(wrapper_pool[0]); i++)		if(spin_trylock(&wrapper_pool[i].lock) == 0)			return &wrapper_pool[i];	return NULL;}
开发者ID:kstraube,项目名称:hysim,代码行数:9,


示例16: ctr_paes_crypt

static int ctr_paes_crypt(struct blkcipher_desc *desc, unsigned long modifier,			  struct blkcipher_walk *walk){	struct s390_paes_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);	u8 buf[AES_BLOCK_SIZE], *ctrptr;	unsigned int nbytes, n, k;	int ret, locked;	locked = spin_trylock(&ctrblk_lock);	ret = blkcipher_walk_virt_block(desc, walk, AES_BLOCK_SIZE);	while ((nbytes = walk->nbytes) >= AES_BLOCK_SIZE) {		n = AES_BLOCK_SIZE;		if (nbytes >= 2*AES_BLOCK_SIZE && locked)			n = __ctrblk_init(ctrblk, walk->iv, nbytes);		ctrptr = (n > AES_BLOCK_SIZE) ? ctrblk : walk->iv;		k = cpacf_kmctr(ctx->fc | modifier, ctx->pk.protkey,				walk->dst.virt.addr, walk->src.virt.addr,				n, ctrptr);		if (k) {			if (ctrptr == ctrblk)				memcpy(walk->iv, ctrptr + k - AES_BLOCK_SIZE,				       AES_BLOCK_SIZE);			crypto_inc(walk->iv, AES_BLOCK_SIZE);			ret = blkcipher_walk_done(desc, walk, nbytes - n);		}		if (k < n) {			if (__ctr_paes_set_key(ctx) != 0) {				if (locked)					spin_unlock(&ctrblk_lock);				return blkcipher_walk_done(desc, walk, -EIO);			}		}	}	if (locked)		spin_unlock(&ctrblk_lock);	/*	 * final block may be < AES_BLOCK_SIZE, copy only nbytes	 */	if (nbytes) {		while (1) {			if (cpacf_kmctr(ctx->fc | modifier,					ctx->pk.protkey, buf,					walk->src.virt.addr, AES_BLOCK_SIZE,					walk->iv) == AES_BLOCK_SIZE)				break;			if (__ctr_paes_set_key(ctx) != 0)				return blkcipher_walk_done(desc, walk, -EIO);		}		memcpy(walk->dst.virt.addr, buf, nbytes);		crypto_inc(walk->iv, AES_BLOCK_SIZE);		ret = blkcipher_walk_done(desc, walk, 0);	}	return ret;}
开发者ID:BWhitten,项目名称:linux-stable,代码行数:56,


示例17: iprintcanlock

static int iprintcanlock(spinlock_t * l){    int i;    for (i = 0; i < 1000; i++) {        if (spin_trylock(l))            return 1;    }    return 0;}
开发者ID:ihategit,项目名称:akaros,代码行数:10,


示例18: stop_machine_run

int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu){    cpumask_t allbutself;    unsigned int i, nr_cpus;    int ret;    BUG_ON(!local_irq_is_enabled());    allbutself = cpu_online_map;    cpu_clear(smp_processor_id(), allbutself);    nr_cpus = cpus_weight(allbutself);    if ( nr_cpus == 0 )    {        BUG_ON(cpu != smp_processor_id());        return (*fn)(data);    }    /* Note: We shouldn't spin on lock when it's held by others since others     * is expecting this cpus to enter softirq context. Or else deadlock     * is caused.     */    if ( !spin_trylock(&stopmachine_lock) )        return -EBUSY;    stopmachine_data.fn = fn;    stopmachine_data.fn_data = data;    stopmachine_data.nr_cpus = nr_cpus;    stopmachine_data.fn_cpu = cpu;    atomic_set(&stopmachine_data.done, 0);    stopmachine_data.state = STOPMACHINE_START;    smp_wmb();    for_each_cpu_mask ( i, allbutself )        cpu_raise_softirq(i, STOPMACHINE_SOFTIRQ);    stopmachine_set_state(STOPMACHINE_PREPARE);    local_irq_disable();    stopmachine_set_state(STOPMACHINE_DISABLE_IRQ);    if ( cpu == smp_processor_id() )        stopmachine_data.fn_result = (*fn)(data);    stopmachine_set_state(STOPMACHINE_INVOKE);    ret = stopmachine_data.fn_result;    stopmachine_set_state(STOPMACHINE_EXIT);    local_irq_enable();    spin_unlock(&stopmachine_lock);    return ret;}
开发者ID:a2k2,项目名称:xen-unstable,代码行数:54,


示例19: dump_smp_call_function

/* * dump version of smp_call_function to avoid deadlock in call_lock */void dump_smp_call_function (void (*func) (void *info), void *info){	static struct call_data_struct dumpdata;	static int dumping_cpu = -1;	int waitcount;	spin_lock(&dump_call_lock);	/*	 * The cpu that reaches here first will do dumping.  Only the dumping	 * cpu skips the if-statement below ONLY ONCE.  The other cpus freeze	 * themselves here.	 */	if (dumpdata.func) {		spin_unlock(&dump_call_lock);		/*		 * The dumping cpu reaches here in case that the netdump starts		 * after the diskdump fails.  In the case, the dumping cpu		 * needs to return to continue the netdump.  In other cases,		 * freezes itself by calling func().		 */		if (dumping_cpu == smp_processor_id())			return;		func(info);		for (;;);		/* NOTREACHED */	}	dumping_cpu = smp_processor_id();	/* freeze call_lock or wait for on-going IPIs to settle down */	waitcount = 0;	while (!spin_trylock(&call_lock)) {		if (waitcount++ > 1000) {			/* save original for dump analysis */			saved_call_data = call_data;			break;		}		udelay(1000);		barrier();	}	dumpdata.func = func;	dumpdata.info = info;	dumpdata.wait = 0; /* not used */	atomic_set(&dumpdata.started, 0); /* not used */	atomic_set(&dumpdata.finished, 0); /* not used */	call_data = &dumpdata;	mb();	send_IPI_allbutself(IPI_CALL_FUNC);	/* Don't wait */	spin_unlock(&dump_call_lock);}
开发者ID:dduval,项目名称:kernel-rhel3,代码行数:57,


示例20: mv_otg_resume

static int mv_otg_resume(struct platform_device *dev){	struct mv_otg *mvotg = platform_get_drvdata(dev);	if (spin_trylock(&mvotg->wq_lock)) {		mv_otg_run_state_machine(mvotg, 0);		spin_unlock(&mvotg->wq_lock);	}	return 0;}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.kernel,代码行数:11,


示例21: panic

/* * Quickly disable system interrupts upon entrance! Now the * kernel is in an inconsistent state, just gracefully stop * the machine and halt :-( * * An interesting case faced from not disabling interrupts * early on (disabling them at the function end instead) was * having other threads getting scheduled between printk() * and disabling interrupts, scrolling-away the caller panic * message and losing information FOREVER. */void __no_return panic(const char *fmt, ...){	va_list args;	int n;	/* NOTE! Do not put anything above this */	local_irq_disable();	/*	 * NOTE! Manually assure that all the functions called	 * below are void of any asserts or panics.	 */	/* Avoid concurrent panic()s: first call holds the most	 * important facts; the rest are usually side-effects. */	if (!spin_trylock(&panic_lock))		goto halt;	/* If other cores are alive, send them a fixed IPI, which	 * intentionally avoids interrupting cores with IF=0 till	 * they re-accept interrupts. Why?	 *	 * An interrupted critical region may  deadlock our panic	 * code if we tried to  acquire the same lock.  The other	 * cores may not also be in  long-mode before they enable	 * interrupts (e.g. in the 16-bit SMP trampoline step.)	 *	 * IPIs are sent only if more than one core is alive:  we	 * might be on so early a stage that our APIC registers	 * are not yet memory mapped, leading to memory faults if	 * locally accessed!	 *	 * If destination CPUs were alive but have not yet inited	 * their local APICs, they will not be able to catch this	 * IPI and will normally continue execution.  Beware.	 */	if (smpboot_get_nr_alive_cpus() > 1)		apic_broadcast_ipi(APIC_DELMOD_FIXED, HALT_CPU_IPI_VECTOR);	va_start(args, fmt);	n = vsnprintf(buf, sizeof(buf) - 1, fmt, args);	va_end(args);	buf[n] = 0;	printk("/nCPU#%d-PANIC: %s", percpu_addr(arch)->apic_id, buf);	/* Since the  other cores are stopped only after they re-	 * accept interrupts, they may print on-screen and scroll	 * away our message.  Acquire all screen locks, forever. */	printk_bust_all_locks();halt:	halt();}
开发者ID:KarimAllah,项目名称:Cute,代码行数:65,


示例22: sv_destroy

void sv_destroy(sv_t *sv) {	if(!spin_trylock(&sv->sv_lock)) {		printk(KERN_ERR "sv_destroy: someone else has sv 0x%p locked!/n", (void *)sv);		BUG();	}	/* XXX Check that the waitqueue is empty? 	       Mark the sv destroyed?	*/}
开发者ID:dduval,项目名称:kernel-rhel3,代码行数:11,


示例23: mlx4_en_tx_irq

void mlx4_en_tx_irq(struct mlx4_cq *mcq){	struct mlx4_en_cq *cq = container_of(mcq, struct mlx4_en_cq, mcq);	struct mlx4_en_priv *priv = netdev_priv(cq->dev);	struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring];	if (!spin_trylock(&ring->comp_lock))		return;	mlx4_en_process_tx_cq(cq->dev, cq);	mod_timer(&cq->timer, jiffies + 1);	spin_unlock(&ring->comp_lock);}
开发者ID:ldesiqueira,项目名称:freebsd_mlx5en,代码行数:12,


示例24: ipmr_expire_process

static void ipmr_expire_process(unsigned long dummy){	if (!spin_trylock(&mfc_unres_lock)) {		mod_timer(&ipmr_expire_timer, jiffies + 1);		return;	}	if (atomic_read(&cache_resolve_queue_len))		ipmr_do_expire_process(dummy);	spin_unlock(&mfc_unres_lock);}
开发者ID:IgnasD,项目名称:Tomato-RAF,代码行数:12,


示例25: ipmr_expire_process

static void ipmr_expire_process(unsigned long dummy){	if (!spin_trylock(&mfc_unres_lock)) {		mod_timer(&ipmr_expire_timer, jiffies + 1);		return;	}	if (mfc_unres_queue != NULL)		ipmr_do_expire_process(dummy);	spin_unlock(&mfc_unres_lock);}
开发者ID:vps2fast,项目名称:openvz-kernel,代码行数:12,


示例26: mv_otg_timer_await_bcon

static void mv_otg_timer_await_bcon(unsigned long data){	struct mv_otg *mvotg = (struct mv_otg *) data;	mvotg->otg_ctrl.a_wait_bcon_timeout = 1;	dev_info(&mvotg->pdev->dev, "B Device No Response!/n");	if (spin_trylock(&mvotg->wq_lock)) {		mv_otg_run_state_machine(mvotg, 0);		spin_unlock(&mvotg->wq_lock);	}}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:13,


示例27: native_smp_send_stop

static void native_smp_send_stop(void){    /* Don't deadlock on the call lock in panic */    int nolock = !spin_trylock(&call_lock);    unsigned long flags;    local_irq_save(flags);    __smp_call_function(stop_this_cpu, NULL, 0, 0);    if (!nolock)        spin_unlock(&call_lock);    disable_local_APIC();    local_irq_restore(flags);}
开发者ID:helicopter3,项目名称:wl500g,代码行数:13,



注:本文中的spin_trylock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ spin_unlock函数代码示例
C++ spin_lock_irqsave函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。