本文整理汇总了C++中rt_exit_critical函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_exit_critical函数的具体用法?C++ rt_exit_critical怎么用?C++ rt_exit_critical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_exit_critical函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rt_usb_alloc_instance
/**
* This function will allocate an usb device instance from system.
*
* @param parent the hub instance to which the new allocated device attached.
* @param port the hub port.
*
* @return the allocate instance on successful, or RT_NULL on failure.
*/
uinst_t rt_usb_alloc_instance(void)
{
int i;
/* lock scheduler */
rt_enter_critical();
for(i = 0; i < USB_MAX_DEVICE; i++)
{
/* to find an idle instance handle */
if(uinst[i].status != UINST_STATUS_IDLE) continue;
/* initialize the usb device instance */
rt_memset(&uinst[i], 0, sizeof(struct uinstance));
uinst[i].status = UINST_STATUS_BUSY;
uinst[i].index = i + 1;
uinst[i].address = 0;
uinst[i].max_packet_size = 0x8;
/* unlock scheduler */
rt_exit_critical();
return &uinst[i];
}
/* unlock scheduler */
rt_exit_critical();
return RT_NULL;
}
开发者ID:nathanlnw,项目名称:tw705_HB_gghypt,代码行数:38,代码来源:core.c
示例2: rt_module_find
/**
* This function will find the specified module.
*
* @param name the name of module finding
*
* @return the module
*/
rt_module_t rt_module_find(const char *name)
{
struct rt_object_information *information;
struct rt_object *object;
struct rt_list_node *node;
extern struct rt_object_information rt_object_container[];
RT_DEBUG_NOT_IN_INTERRUPT;
/* enter critical */
rt_enter_critical();
/* try to find device object */
information = &rt_object_container[RT_Object_Class_Module];
for (node = information->object_list.next;
node != &(information->object_list);
node = node->next)
{
object = rt_list_entry(node, struct rt_object, list);
if (rt_strncmp(object->name, name, RT_NAME_MAX) == 0)
{
/* leave critical */
rt_exit_critical();
return (rt_module_t)object;
}
}
/* leave critical */
rt_exit_critical();
/* not found */
return RT_NULL;
}
开发者ID:Cheong2K,项目名称:rt-thread,代码行数:42,代码来源:module_win32.c
示例3: pthread_mutex_lock
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
int mtype;
rt_err_t result;
if (!mutex) return EINVAL;
if (mutex->attr == -1)
{
/* init mutex */
pthread_mutex_init(mutex, RT_NULL);
}
mtype = mutex->attr & MUTEXATTR_TYPE_MASK;
rt_enter_critical();
if (mutex->lock.owner == rt_thread_self() && mtype != PTHREAD_MUTEX_RECURSIVE)
{
rt_exit_critical();
return EDEADLK;
}
rt_exit_critical();
result = rt_mutex_take(&(mutex->lock), RT_WAITING_FOREVER);
if (result == RT_EOK) return 0;
return EINVAL;
}
开发者ID:bobo8909,项目名称:RTT,代码行数:27,代码来源:pthread_mutex.c
示例4: pthread_cond_broadcast
int pthread_cond_broadcast(pthread_cond_t *cond)
{
rt_err_t result;
if (cond->attr == -1)
pthread_cond_init(cond, RT_NULL);
rt_enter_critical();
while (1)
{
/* try to take condition semaphore */
result = rt_sem_trytake(&(cond->sem));
if (result == -RT_ETIMEOUT)
{
/* it's timeout, release this semaphore */
rt_sem_release(&(cond->sem));
}
else if (result == RT_EOK)
{
/* has taken this semaphore, release it */
rt_sem_release(&(cond->sem));
break;
}
else
{
rt_exit_critical();
return EINVAL;
}
}
rt_exit_critical();
return 0;
}
开发者ID:cedar-renjun,项目名称:air-conditioning-assistant,代码行数:33,代码来源:pthread_cond.c
示例5: tcpip_init_done_callback
static void tcpip_init_done_callback(void *arg)
{
rt_device_t device;
struct eth_device *ethif;
struct ip_addr ipaddr, netmask, gw;
struct rt_list_node* node;
struct rt_object* object;
struct rt_object_information *information;
extern struct rt_object_information rt_object_container[];
LWIP_ASSERT("invalid arg.\n",arg);
IP4_ADDR(&gw, 0,0,0,0);
IP4_ADDR(&ipaddr, 0,0,0,0);
IP4_ADDR(&netmask, 0,0,0,0);
/* enter critical */
rt_enter_critical();
/* for each network interfaces */
information = &rt_object_container[RT_Object_Class_Device];
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
{
object = rt_list_entry(node, struct rt_object, list);
device = (rt_device_t) object;
if (device->type == RT_Device_Class_NetIf)
{
ethif = (struct eth_device*)device;
/* leave critical */
rt_exit_critical();
netif_add(ethif->netif, &ipaddr, &netmask, &gw,
ethif, netif_device_init, tcpip_input);
if (netif_default == NULL)
netif_set_default(ethif->netif);
#if LWIP_DHCP
dhcp_start(ethif->netif);
#else
netif_set_up(ethif->netif);
#endif
#ifdef LWIP_NETIF_LINK_CALLBACK
netif_set_link_up(ethif->netif);
#endif
/* enter critical */
rt_enter_critical();
}
}
/* leave critical */
rt_exit_critical();
rt_sem_release((rt_sem_t)arg);
}
开发者ID:haitao52198,项目名称:HD-Elastos,代码行数:59,代码来源:sys_arch_init.c
示例6: pthread_cleanup_pop
void pthread_cleanup_pop(int execute)
{
_pthread_data_t* ptd;
_pthread_cleanup_t* cleanup;
/* get posix thread data */
ptd = _pthread_get_data(rt_thread_self());
RT_ASSERT(ptd != RT_NULL);
if (execute)
{
rt_enter_critical();
cleanup = ptd->cleanup;
if (cleanup)
ptd->cleanup = cleanup->next;
rt_exit_critical();
if (cleanup)
{
cleanup->cleanup_func(cleanup->parameter);
rt_free(cleanup);
}
}
}
开发者ID:dlts200466,项目名称:PowerSupply,代码行数:25,代码来源:pthread.c
示例7: _sleep_entry
static void _sleep_entry(void)
{
rt_tick_t timeout;
rt_uint32_t ms;
rt_uint32_t count;
system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);
timeout = rt_timer_next_timeout_tick() - rt_tick_get();
ms = timeout * (1000 / RT_TICK_PER_SECOND);
rt_kprintf("os tick:%u entry sleep:%u tick\r\n", rt_tick_get(), timeout);
_rtc_timer_start(ms);
system_sleep();
rt_enter_critical();
count = rtc_count_get_count(&rtc_instance);
ms = (count + 32) / 32.768;
rtc_count_disable(&rtc_instance);
sleep_tick_adjust(ms);
timeout = rt_tick_get();
rt_exit_critical();
rt_kprintf("sleep exited, os tick:%u\n", timeout);
}
开发者ID:csz-cmy,项目名称:rt-thread,代码行数:25,代码来源:sleep_timer.c
示例8: list_tcps
void list_tcps()
{
struct tcp_pcb *pcb;
extern struct tcp_pcb *tcp_active_pcbs;
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
extern struct tcp_pcb *tcp_tw_pcbs;
extern const char *tcp_state_str[];
rt_enter_critical();
printf_syn("Active PCB states:\n");
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
printf_syn("%s:%d <==> %s:%d snd_nxt %d rcv_nxt %d ",
inet_ntoa(*((struct in_addr*)&(pcb->local_ip))), pcb->local_port,
inet_ntoa(*((struct in_addr*)&(pcb->remote_ip))), pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt);
printf_syn("state: %s\n", tcp_state_str[pcb->state]);
}
printf_syn("Listen PCB states:\n");
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) {
printf_syn("local port %d ", pcb->local_port);
printf_syn("state: %s\n", tcp_state_str[pcb->state]);
}
printf_syn("TIME-WAIT PCB states:\n");
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
printf_syn("%s:%d <==> %s:%d snd_nxt %d rcv_nxt %d ",
inet_ntoa(*((struct in_addr*)&(pcb->local_ip))), pcb->local_port,
inet_ntoa(*((struct in_addr*)&(pcb->remote_ip))), pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt);
printf_syn("state: %s\n", tcp_state_str[pcb->state]);
}
rt_exit_critical();
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:34,代码来源:stm32netif.c
示例9: rt_signal_install
rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler)
{
rt_sighandler_t old;
rt_thread_t tid = rt_thread_self();
if (!sig_valid(signo)) return SIG_ERR;
rt_enter_critical();
if (tid->sig_vectors == RT_NULL)
{
rt_thread_alloc_sig(tid);
}
if (tid->sig_vectors)
{
old = tid->sig_vectors[signo];
if (handler == SIG_IGN) tid->sig_vectors[signo] = RT_NULL;
else if (handler == SIG_DFL) tid->sig_vectors[signo] = _signal_default_handler;
else tid->sig_vectors[signo] = handler;
}
rt_exit_critical();
return old;
}
开发者ID:onelife,项目名称:rt-thread,代码行数:25,代码来源:signal.c
示例10: pthread_exit
void pthread_exit (void* value)
{
_pthread_data_t* ptd;
_pthread_cleanup_t* cleanup;
extern _pthread_key_data_t _thread_keys[PTHREAD_KEY_MAX];
ptd = _pthread_get_data(rt_thread_self());
rt_enter_critical();
/* disable cancel */
ptd->cancelstate = PTHREAD_CANCEL_DISABLE;
/* set return value */
ptd->return_value = value;
rt_exit_critical();
/* invoke pushed cleanup */
while (ptd->cleanup != RT_NULL)
{
cleanup = ptd->cleanup;
ptd->cleanup = cleanup->next;
cleanup->cleanup_func(cleanup->parameter);
/* release this cleanup function */
rt_free(cleanup);
}
/* destruct thread local key */
if (ptd->tls != RT_NULL)
{
void* data;
rt_uint32_t index;
for (index = 0; index < PTHREAD_KEY_MAX; index ++)
{
if (_thread_keys[index].is_used)
{
data = ptd->tls[index];
if (data)
_thread_keys[index].destructor(data);
}
}
/* release tls area */
rt_free(ptd->tls);
ptd->tls = RT_NULL;
}
if (ptd->attr.detachstate == PTHREAD_CREATE_JOINABLE)
{
/* release the joinable pthread */
rt_sem_release(ptd->joinable_sem);
}
/* detach thread */
rt_thread_detach(ptd->tid);
/* reschedule thread */
rt_schedule();
}
开发者ID:dlts200466,项目名称:PowerSupply,代码行数:58,代码来源:pthread.c
示例11: pthread_once
int pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
{
RT_ASSERT(once_control != RT_NULL);
RT_ASSERT(init_routine != RT_NULL);
rt_enter_critical();
if (!(*once_control))
{
/* call routine once */
*once_control = 1;
rt_exit_critical();
init_routine();
}
rt_exit_critical();
return 0;
}
开发者ID:dlts200466,项目名称:PowerSupply,代码行数:18,代码来源:pthread.c
示例12: list_tcps
void list_tcps(void)
{
UInt32 num = 0;
struct tcp_pcb *pcb;
char local_ip_str[16];
char remote_ip_str[16];
extern struct tcp_pcb *tcp_active_pcbs;
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
extern struct tcp_pcb *tcp_tw_pcbs;
extern const char *tcp_state_str[];
rt_enter_critical();
printf("Active PCB states:\n");
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next)
{
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
printf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ",
num++,
local_ip_str,
pcb->local_port,
remote_ip_str,
pcb->remote_port,
pcb->snd_nxt,
pcb->rcv_nxt);
printf("state: %s\n", tcp_state_str[pcb->state]);
}
printf("Listen PCB states:\n");
num = 0;
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next)
{
printf("#%d local port %d ", num++, pcb->local_port);
printf("state: %s\n", tcp_state_str[pcb->state]);
}
printf("TIME-WAIT PCB states:\n");
num = 0;
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next)
{
strcpy(local_ip_str, ipaddr_ntoa(&(pcb->local_ip)));
strcpy(remote_ip_str, ipaddr_ntoa(&(pcb->remote_ip)));
printf("#%d %s:%d <==> %s:%d snd_nxt 0x%08X rcv_nxt 0x%08X ",
num++,
local_ip_str,
pcb->local_port,
remote_ip_str,
pcb->remote_port,
pcb->snd_nxt,
pcb->rcv_nxt);
printf("state: %s\n", tcp_state_str[pcb->state]);
}
rt_exit_critical();
}
开发者ID:haitao52198,项目名称:HD-Elastos,代码行数:57,代码来源:ethernetif.c
示例13: rt_thread_kill
int rt_thread_kill(rt_thread_t tid, int sig)
{
siginfo_t si;
rt_base_t level;
struct siginfo_node *si_node;
RT_ASSERT(tid != RT_NULL);
if (!sig_valid(sig)) return -RT_EINVAL;
dbg_log(DBG_INFO, "send signal: %d\n", sig);
si.si_errno = RT_EINTR;
si.si_signo = sig;
si.si_code = SI_USER;
si.si_value.sival_ptr = RT_NULL;
level = rt_hw_interrupt_disable();
if (tid->sig_pending & sig_mask(sig))
{
/* whether already emits this signal? */
struct rt_slist_node *node;
struct siginfo_node *entry;
node = (struct rt_slist_node *)tid->si_list;
rt_hw_interrupt_enable(level);
/* update sig infor */
rt_enter_critical();
for (; (node) != RT_NULL; node = node->next)
{
entry = rt_slist_entry(node, struct siginfo_node, list);
if (entry->si.si_signo == sig)
{
memcpy(&(entry->si), &si, sizeof(siginfo_t));
rt_exit_critical();
return 0;
}
}
rt_exit_critical();
/* disable interrupt to protect tcb */
level = rt_hw_interrupt_disable();
}
else
{
开发者ID:onelife,项目名称:rt-thread,代码行数:44,代码来源:signal.c
示例14: Setting_Write
/*
void Setting_Write(void)
{
uint8_t t;
while (1)
{
IIC_WriteSeq(AT24C32_ADDRESS,SETTING_BASE,Setting,SETTING_LENGTH);
rt_thread_delay_hmsm(0,0,0,100);
IIC_ReadSeq(AT24C32_ADDRESS,SETTING_BASE+1, &t,1);
if (t!=Setting[1])
rt_thread_delay_hmsm(0,0,0,100);
else
break;
}
return;
}
void Setting_Read(void)
{
IIC_ReadSeq(AT24C32_ADDRESS,SETTING_BASE,Setting,SETTING_LENGTH);
return;
}
void pomodoro_set(uint8_t a,uint8_t b,uint8_t c)
{
Setting[POMODORO_TIME] = a;
Setting[POMODORO_BREAK_TIME] = b;
Setting[POMODORO_REST_TIME] = c;
Setting_Write();
return;
}
FINSH_FUNCTION_EXPORT_ALIAS(pomodoro_set,pomodoro,Set Interval of Pomodoro Clock(Working,Break,Rest))
*/
void time(void)
{
rt_enter_critical();
rt_kprintf(" Date:\t20%x-%x-%x\n Time:\t%x:%x:%x\n Temperature:\t%d C\n",\
IIC_Read(DS3231_ADDRESS, DS3231_YEAR),IIC_Read(DS3231_ADDRESS,DS3231_MONTH)&0x7f,IIC_Read(DS3231_ADDRESS,DS3231_DAY),\
IIC_Read(DS3231_ADDRESS, DS3231_HOUR),IIC_Read(DS3231_ADDRESS,DS3231_MINUTE),IIC_Read(DS3231_ADDRESS,DS3231_SECOND),\
IIC_Read(DS3231_ADDRESS, DS3231_TEMP_MSB));
rt_exit_critical();
return;
}
开发者ID:KNCheung,项目名称:AlarmClockBeta,代码行数:42,代码来源:usr_cmd.c
示例15: pthread_key_delete
int pthread_key_delete(pthread_key_t key)
{
if (key >= PTHREAD_KEY_MAX) return EINVAL;
rt_enter_critical();
_thread_keys[key].is_used = 0;
_thread_keys[key].destructor = 0;
rt_exit_critical();
return 0;
}
开发者ID:Andy51,项目名称:rt-thread,代码行数:11,代码来源:pthread_tls.c
示例16: dfs_device_fs_open
int dfs_device_fs_open(struct dfs_fd *file)
{
rt_err_t result;
rt_device_t device;
if (file->flags & DFS_O_CREAT)
return -DFS_STATUS_EINVAL;
/* open root directory */
if ((file->path[0] == '/') && (file->path[1] == '\0') &&
(file->flags & DFS_O_DIRECTORY))
{
struct rt_object *object;
struct rt_list_node *node;
struct rt_object_information *information;
struct device_dirent *root_dirent;
rt_uint32_t count = 0;
extern struct rt_object_information rt_object_container[];
/* lock scheduler */
rt_enter_critical();
/* traverse device object */
information = &rt_object_container[RT_Object_Class_Device];
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
{
count ++;
}
root_dirent = (struct device_dirent *)rt_malloc(sizeof(struct device_dirent) +
count * sizeof(rt_device_t));
if (root_dirent != RT_NULL)
{
root_dirent->devices = (rt_device_t *)(root_dirent + 1);
root_dirent->read_index = 0;
root_dirent->device_count = count;
count = 0;
/* get all device node */
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
{
object = rt_list_entry(node, struct rt_object, list);
root_dirent->devices[count] = (rt_device_t)object;
count ++;
}
}
rt_exit_critical();
/* set data */
file->data = root_dirent;
return DFS_STATUS_OK;
}
开发者ID:1847123212,项目名称:SFUD,代码行数:53,代码来源:devfs.c
示例17: pthread_key_create
int pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
{
rt_uint32_t index;
rt_enter_critical();
for (index = 0; index < PTHREAD_KEY_MAX; index ++)
{
if (_thread_keys[index].is_used == 0)
{
_thread_keys[index].is_used = 1;
_thread_keys[index].destructor = destructor;
*key = index;
rt_exit_critical();
return 0;
}
}
rt_exit_critical();
return EAGAIN;
}
开发者ID:Andy51,项目名称:rt-thread,代码行数:22,代码来源:pthread_tls.c
示例18: list_if
void list_if(void)
{
rt_ubase_t index;
struct netif * netif;
rt_enter_critical();
netif = netif_list;
while( netif != NULL )
{
printf("network interface: %c%c%s\n",
netif->name[0],
netif->name[1],
(netif == netif_default)?" (Default)":"");
printf("MTU: %d\n", netif->mtu);
printf("MAC: ");
for (index = 0; index < netif->hwaddr_len; index ++)
printf("%02x ", netif->hwaddr[index]);
printf("\nFLAGS:");
if (netif->flags & NETIF_FLAG_UP) printf(" UP");
else printf(" DOWN");
if (netif->flags & NETIF_FLAG_LINK_UP) printf(" LINK_UP");
else printf(" LINK_DOWN");
if (netif->flags & NETIF_FLAG_DHCP) printf(" DHCP");
if (netif->flags & NETIF_FLAG_POINTTOPOINT) printf(" PPP");
if (netif->flags & NETIF_FLAG_ETHARP) printf(" ETHARP");
if (netif->flags & NETIF_FLAG_IGMP) printf(" IGMP");
printf("\n");
printf("ip address: %s\n", ipaddr_ntoa(&(netif->ip_addr)));
printf("gw address: %s\n", ipaddr_ntoa(&(netif->gw)));
printf("net mask : %s\n", ipaddr_ntoa(&(netif->netmask)));
printf("\r\n");
netif = netif->next;
}
#if LWIP_DNS
{
struct ip_addr ip_addr;
for(index=0; index<DNS_MAX_SERVERS; index++)
{
ip_addr = dns_getserver(index);
printf("dns server #%d: %s\n", index, ipaddr_ntoa(&(ip_addr)));
}
}
#endif /**< #if LWIP_DNS */
rt_exit_critical();
}
开发者ID:haitao52198,项目名称:HD-Elastos,代码行数:51,代码来源:ethernetif.c
示例19: rt_object_find
/**
* This function will find specified name object from object
* container.
*
* @param name the specified name of object.
* @param type the type of object
*
* @return the found object or RT_NULL if there is no this object
* in object container.
*
* @note this function shall not be invoked in interrupt status.
*/
rt_object_t rt_object_find(const char* name, rt_uint8_t type)
{
struct rt_object* object;
struct rt_list_node* node;
struct rt_object_information *information;
extern volatile rt_uint8_t rt_interrupt_nest;
/* parameter check */
if ((name == RT_NULL) ||
(type > RT_Object_Class_Unknown))
return RT_NULL;
/* which is invoke in interrupt status */
if (rt_interrupt_nest != 0)
RT_ASSERT(0);
/* enter critical */
rt_enter_critical();
/* try to find object */
information = &rt_object_container[type];
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
{
object = rt_list_entry(node, struct rt_object, list);
if (rt_strncmp(object->name, name, RT_NAME_MAX) == 0)
{
/* leave critical */
rt_exit_critical();
return (rt_object_t)object;
}
}
/* leave critical */
rt_exit_critical();
return RT_NULL;
}
开发者ID:comrid1987,项目名称:jb3500,代码行数:50,代码来源:object.c
示例20: _tc_cleanup
static void _tc_cleanup()
{
/* lock scheduler */
rt_enter_critical();
/* delete thread */
if (tid1 != RT_NULL && tid1->stat != RT_THREAD_CLOSE)
tc_stat(TC_STAT_FAILED);
if (tid2 != RT_NULL && tid2->stat != RT_THREAD_CLOSE)
tc_stat(TC_STAT_FAILED);
/* unlock scheduler */
rt_exit_critical();
}
开发者ID:CollinsLiu,项目名称:rt-thread-pc,代码行数:14,代码来源:thread_delete.c
注:本文中的rt_exit_critical函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论