本文整理汇总了C++中xnlock_get_irqsave函数的典型用法代码示例。如果您正苦于以下问题:C++ xnlock_get_irqsave函数的具体用法?C++ xnlock_get_irqsave怎么用?C++ xnlock_get_irqsave使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xnlock_get_irqsave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: format_irq_proc
static int format_irq_proc(unsigned int irq, char *str)
{
xnintr_t *intr;
char *p = str;
spl_t s;
if (rthal_virtual_irq_p(irq)) {
p += sprintf(p, " [virtual]");
return p - str;
} else if (irq == XNARCH_TIMER_IRQ) {
p += sprintf(p, " [timer]");
return p - str;
#ifdef CONFIG_SMP
} else if (irq == RTHAL_SERVICE_IPI0) {
p += sprintf(p, " [IPI]");
return p - str;
} else if (irq == RTHAL_CRITICAL_IPI) {
p += sprintf(p, " [critical sync]");
return p - str;
#endif /* CONFIG_SMP */
}
xnlock_get_irqsave(&intrlock, s);
intr = xnintr_shirq_first(irq);
if (intr) {
strcpy(p, " "); p += 8;
do {
*p = ' '; p += 1;
strcpy(p, intr->name); p += strlen(intr->name);
intr = xnintr_shirq_next(intr);
} while (intr);
}
xnlock_put_irqrestore(&intrlock, s);
return p - str;
}
示例2: ref_flg
ER ref_flg(T_RFLG *pk_rflg, ID flgid)
{
uitask_t *sleeper;
uiflag_t *flag;
ER err = E_OK;
spl_t s;
if (xnpod_asynch_p())
return EN_CTXID;
if (flgid <= 0 || flgid > uITRON_MAX_FLAGID)
return E_ID;
xnlock_get_irqsave(&nklock, s);
flag = xnmap_fetch(ui_flag_idmap, flgid);
if (!flag) {
err = E_NOEXS;
goto unlock_and_exit;
}
if (xnsynch_pended_p(&flag->synchbase)) {
xnpholder_t *holder = getheadpq(xnsynch_wait_queue(&flag->synchbase));
xnthread_t *thread = link2thread(holder, plink);
sleeper = thread2uitask(thread);
pk_rflg->wtsk = sleeper->id;
} else
pk_rflg->wtsk = FALSE;
pk_rflg->exinf = flag->exinf;
pk_rflg->flgptn = flag->flgvalue;
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return err;
}
示例3: rt_event_create
int rt_event_create(RT_EVENT *event,
const char *name, unsigned long ivalue, int mode)
{
int err = 0;
spl_t s;
if (xnpod_asynch_p())
return -EPERM;
xnsynch_init(&event->synch_base, mode & EV_PRIO, NULL);
event->value = ivalue;
event->handle = 0; /* i.e. (still) unregistered event. */
event->magic = XENO_EVENT_MAGIC;
xnobject_copy_name(event->name, name);
inith(&event->rlink);
event->rqueue = &xeno_get_rholder()->eventq;
xnlock_get_irqsave(&nklock, s);
appendq(event->rqueue, &event->rlink);
xnlock_put_irqrestore(&nklock, s);
#ifdef CONFIG_XENO_OPT_PERVASIVE
event->cpid = 0;
#endif /* CONFIG_XENO_OPT_PERVASIVE */
/*
* <!> Since xnregister_enter() may reschedule, only register
* complete objects, so that the registry cannot return
* handles to half-baked objects...
*/
if (name) {
err = xnregistry_enter(event->name, event, &event->handle,
&__event_pnode);
if (err)
rt_event_delete(event);
}
return err;
}
示例4: rt_buffer_delete
int rt_buffer_delete(RT_BUFFER *bf)
{
int ret = 0, resched;
spl_t s;
if (xnpod_asynch_p())
return -EPERM;
xnlock_get_irqsave(&nklock, s);
bf = xeno_h2obj_validate(bf, XENO_BUFFER_MAGIC, RT_BUFFER);
if (bf == NULL) {
ret = xeno_handle_error(bf, XENO_BUFFER_MAGIC, RT_BUFFER);
goto unlock_and_exit;
}
xnarch_free_host_mem(bf->bufmem, bf->bufsz);
removeq(bf->rqueue, &bf->rlink);
resched = xnsynch_destroy(&bf->isynch_base) == XNSYNCH_RESCHED;
resched += xnsynch_destroy(&bf->osynch_base) == XNSYNCH_RESCHED;
if (bf->handle)
xnregistry_remove(bf->handle);
xeno_mark_deleted(bf);
if (resched)
/*
* Some task has been woken up as a result of the
* deletion: reschedule now.
*/
xnpod_schedule();
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return ret;
}
示例5: pthread_once
/**
* Execute an initialization routine.
*
* This service may be used by libraries which need an initialization function
* to be called only once.
*
* The function @a init_routine will only be called, with no argument, the first
* time this service is called specifying the address @a once.
*
* @return 0 on success;
* @return an error number if:
* - EINVAL, the object pointed to by @a once is invalid (it must have been
* initialized with PTHREAD_ONCE_INIT).
*
* @see
* <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_once.html">
* Specification.</a>
*
*/
int pthread_once(pthread_once_t * once, void (*init_routine) (void))
{
spl_t s;
xnlock_get_irqsave(&nklock, s);
if (!pse51_obj_active(once, PSE51_ONCE_MAGIC, pthread_once_t)) {
xnlock_put_irqrestore(&nklock, s);
return EINVAL;
}
if (!once->routine_called) {
init_routine();
/* If the calling thread is canceled while executing init_routine,
routine_called will not be set to 1. */
once->routine_called = 1;
}
xnlock_put_irqrestore(&nklock, s);
return 0;
}
示例6: t_restart
u_long t_restart(u_long tid, u_long targs[])
{
u_long err = SUCCESS;
psostask_t *task;
spl_t s;
int n;
if (xnpod_unblockable_p())
return -EPERM;
xnlock_get_irqsave(&nklock, s);
if (tid == 0)
task = psos_current_task();
else {
task = psos_h2obj_active(tid, PSOS_TASK_MAGIC, psostask_t);
if (!task) {
err = psos_handle_error(tid, PSOS_TASK_MAGIC, psostask_t);
goto unlock_and_exit;
}
if (xnthread_test_state(&task->threadbase, XNDORMANT)) {
err = ERR_NACTIVE;
goto unlock_and_exit;
}
}
for (n = 0; n < 4; n++)
task->args[n] = targs ? targs[n] : 0;
xnpod_restart_thread(&task->threadbase);
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return err;
}
示例7: sc_minquiry
int sc_minquiry(int mid, int *errp)
{
vrtxmx_t *mx;
spl_t s;
int rc;
xnlock_get_irqsave(&nklock, s);
mx = xnmap_fetch(vrtx_mx_idmap, mid);
if (mx == NULL) {
rc = 0;
*errp = ER_ID;
goto unlock_and_exit;
}
rc = xnsynch_owner(&mx->synchbase) == NULL;
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return rc;
}
示例8: sem_timedwait
/**
* Attempt, during a bounded time, to lock a semaphore.
*
* This serivce is equivalent to sem_wait(), except that the caller is only
* blocked until the timeout @a abs_timeout expires.
*
* @param sm the semaphore to be locked;
*
* @param abs_timeout the timeout, expressed as an absolute value of the
* CLOCK_REALTIME clock.
*
* @retval 0 on success;
* @retval -1 with @a errno set if:
* - EPERM, the caller context is invalid;
* - EINVAL, the semaphore is invalid or uninitialized;
* - EINVAL, the specified timeout is invalid;
* - EPERM, the semaphore @a sm is not process-shared and does not belong to the
* current process;
* - EINTR, the caller was interrupted by a signal while blocked in this
* service;
* - ETIMEDOUT, the semaphore could not be locked and the specified timeout
* expired.
*
* @par Valid contexts:
* - Xenomai kernel-space thread,
* - Xenomai user-space thread (switches to primary mode).
*
* @see
* <a href="http://www.opengroup.org/onlinepubs/000095399/functions/sem_timedwait.html">
* Specification.</a>
*
*/
int sem_timedwait(sem_t * sm, const struct timespec *abs_timeout)
{
struct __shadow_sem *shadow = &((union __xeno_sem *)sm)->shadow_sem;
spl_t s;
int err;
if (abs_timeout->tv_nsec > ONE_BILLION) {
err = EINVAL;
goto error;
}
xnlock_get_irqsave(&nklock, s);
err = sem_timedwait_internal(shadow, 1, ts2ticks_ceil(abs_timeout) + 1);
xnlock_put_irqrestore(&nklock, s);
error:
if (err) {
thread_set_errno(err);
return -1;
}
return 0;
}
示例9: xnlock_get_irqsave
struct xnsched *xnsched_finish_unlocked_switch(struct xnsched *sched)
{
struct xnthread *last;
spl_t s;
xnlock_get_irqsave(&nklock, s);
#ifdef CONFIG_SMP
/* If current thread migrated while suspended */
sched = xnsched_current();
#endif /* CONFIG_SMP */
last = sched->last;
sched->status &= ~XNINSW;
/* Detect a thread which called xnthread_migrate() */
if (last->sched != sched) {
xnsched_putback(last);
xnthread_clear_state(last, XNMIGRATE);
}
return sched;
}
示例10: rt_cond_inquire
int rt_cond_inquire(RT_COND *cond, RT_COND_INFO *info)
{
int err = 0;
spl_t s;
xnlock_get_irqsave(&nklock, s);
cond = xeno_h2obj_validate(cond, XENO_COND_MAGIC, RT_COND);
if (!cond) {
err = xeno_handle_error(cond, XENO_COND_MAGIC, RT_COND);
goto unlock_and_exit;
}
strcpy(info->name, cond->name);
info->nwaiters = xnsynch_nsleepers(&cond->synch_base);
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return err;
}
示例11: lock_vfile_store
static ssize_t lock_vfile_store(struct xnvfile_input *input)
{
ssize_t ret;
spl_t s;
int cpu;
long val;
ret = xnvfile_get_integer(input, &val);
if (ret < 0)
return ret;
if (val != 0)
return -EINVAL;
for_each_realtime_cpu(cpu) {
xnlock_get_irqsave(&nklock, s);
memset(&per_cpu(xnlock_stats, cpu), '\0', sizeof(struct xnlockinfo));
xnlock_put_irqrestore(&nklock, s);
}
return ret;
}
示例12: rt_cond_broadcast
int rt_cond_broadcast(RT_COND *cond)
{
int err = 0;
spl_t s;
xnlock_get_irqsave(&nklock, s);
cond = xeno_h2obj_validate(cond, XENO_COND_MAGIC, RT_COND);
if (!cond) {
err = xeno_handle_error(cond, XENO_COND_MAGIC, RT_COND);
goto unlock_and_exit;
}
if (xnsynch_flush(&cond->synch_base, 0) == XNSYNCH_RESCHED)
xnpod_schedule();
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return err;
}
示例13: t_ident
u_long t_ident(const char *name, u_long node, u_long *tid_r)
{
u_long err = SUCCESS;
xnholder_t *holder;
psostask_t *task;
spl_t s;
if (node > 1)
return ERR_NODENO;
if (!name) {
if (xnpod_unblockable_p())
return ERR_OBJID;
*tid_r = (u_long)psos_current_task();
return SUCCESS;
}
xnlock_get_irqsave(&nklock, s);
for (holder = getheadq(&psostaskq);
holder; holder = nextq(&psostaskq, holder)) {
task = link2psostask(holder);
if (!strcmp(task->name, name)) {
*tid_r = (u_long)task;
goto unlock_and_exit;
}
}
err = ERR_OBJNF;
unlock_and_exit:
xnlock_put_irqrestore(&nklock, s);
return err;
}
示例14: rt_cond_create
int rt_cond_create(RT_COND *cond, const char *name)
{
int err = 0;
spl_t s;
if (xnpod_asynch_p())
return -EPERM;
xnsynch_init(&cond->synch_base, XNSYNCH_PRIO, NULL);
cond->handle = 0; /* i.e. (still) unregistered cond. */
cond->magic = XENO_COND_MAGIC;
xnobject_copy_name(cond->name, name);
inith(&cond->rlink);
cond->rqueue = &xeno_get_rholder()->condq;
xnlock_get_irqsave(&nklock, s);
appendq(cond->rqueue, &cond->rlink);
xnlock_put_irqrestore(&nklock, s);
#ifndef __XENO_SIM__
cond->cpid = 0;
#endif
/*
* <!> Since xnregister_enter() may reschedule, only register
* complete objects, so that the registry cannot return
* handles to half-baked objects...
*/
if (name) {
err = xnregistry_enter(cond->name, cond, &cond->handle,
&__cond_pnode.node);
if (err)
rt_cond_delete(cond);
}
return err;
}
示例15: pthread_mutexattr_setprotocol
/**
* Set the protocol attribute of a mutex attributes object.
*
* This service set the @a type attribute of the mutex attributes object
* @a attr.
*
* @param attr an initialized mutex attributes object,
*
* @param proto value of the @a protocol attribute, may be one of:
* - PTHREAD_PRIO_NONE, meaning that a mutex created with the attributes object
* @a attr will not follow any priority protocol;
* - PTHREAD_PRIO_INHERIT, meaning that a mutex created with the attributes
* object @a attr, will follow the priority inheritance protocol.
*
* The value PTHREAD_PRIO_PROTECT (priority ceiling protocol) is unsupported.
*
* @return 0 on success,
* @return an error number if:
* - EINVAL, the mutex attributes object @a attr is invalid;
* - EOPNOTSUPP, the value of @a proto is unsupported;
* - EINVAL, the value of @a proto is invalid.
*
* @see
* <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutexattr_setprotocol.html">
* Specification.</a>
*
*/
static inline int
pthread_mutexattr_setprotocol(pthread_mutexattr_t * attr, int proto)
{
spl_t s;
if (!attr)
return EINVAL;
xnlock_get_irqsave(&nklock, s);
if (!cobalt_obj_active(attr,COBALT_MUTEX_ATTR_MAGIC,pthread_mutexattr_t)) {
xnlock_put_irqrestore(&nklock, s);
return EINVAL;
}
switch (proto) {
default:
xnlock_put_irqrestore(&nklock, s);
return EINVAL;
case PTHREAD_PRIO_PROTECT:
xnlock_put_irqrestore(&nklock, s);
return EOPNOTSUPP;
case PTHREAD_PRIO_NONE:
case PTHREAD_PRIO_INHERIT:
break;
}
attr->protocol = proto;
xnlock_put_irqrestore(&nklock, s);
return 0;
}