本文整理汇总了C++中rt_thread_init函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_thread_init函数的具体用法?C++ rt_thread_init怎么用?C++ rt_thread_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_thread_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eth_system_device_init
int eth_system_device_init(void)
{
Int32 result = RT_EOK;
/* initialize Rx thread.
* initialize mailbox and create Ethernet Rx thread */
result = rt_mb_init(ð_rx_thread_mb, "erxmb",
ð_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4,
RT_IPC_FLAG_FIFO);
assert(result == RT_EOK);
result = rt_thread_init(ð_rx_thread, "erx", eth_rx_thread_entry, NULL,
ð_rx_thread_stack[0], sizeof(eth_rx_thread_stack),
RT_LWIP_ETHTHREAD_PRIORITY, 16);
assert(result == RT_EOK);
result = rt_thread_startup(ð_rx_thread);
assert(result == RT_EOK);
/* initialize Tx thread */
/* initialize mailbox and create Ethernet Tx thread */
result = rt_mb_init(ð_tx_thread_mb, "etxmb",
ð_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4,
RT_IPC_FLAG_FIFO);
assert(result == RT_EOK);
result = rt_thread_init(ð_tx_thread, "etx", eth_tx_thread_entry, NULL,
ð_tx_thread_stack[0], sizeof(eth_tx_thread_stack),
RT_ETHERNETIF_THREAD_PREORITY, 16);
assert(result == RT_EOK);
result = rt_thread_startup(ð_tx_thread);
assert(result == RT_EOK);
return 0;
}
示例2: rt_application_init
int rt_application_init()
{
rt_thread_init(&thread_led1,
"led1",
thread_led1_entry, RT_NULL,
&thread_led1_stack[0], sizeof(thread_led1_stack),
20, 10);
rt_thread_init(&thread_led2,
"led2",
thread_led2_entry, RT_NULL,
&thread_led2_stack[0], sizeof(thread_led2_stack),
25, 8);
rt_thread_startup(&thread_led1);
rt_thread_startup(&thread_led2);
/* inint SD-crad and dm9000 */
{
rt_thread_t init_thread;
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
1024, 8, 5);
rt_thread_startup(init_thread);
}
return 0;
}
示例3: thread_static_simple_init
int thread_static_simple_init()
{
rt_err_t result;
/* 初始化线程1 */
result = rt_thread_init(&thread1, "t1", /* 线程名:t1 */
thread_entry, (void*)1, /* 线程的入口是thread_entry,入口参数是1 */
&thread1_stack[0], sizeof(thread1_stack), /* 线程栈是thread1_stack */
THREAD_PRIORITY, 10);
if (result == RT_EOK) /* 如果返回正确,启动线程1 */
rt_thread_startup(&thread1);
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
/* 初始化线程2 */
result = rt_thread_init(&thread2, "t2", /* 线程名:t2 */
thread_entry, RT_NULL, /* 线程的入口是thread_entry,入口参数是2 */
&thread2_stack[0], sizeof(thread2_stack), /* 线程栈是thread2_stack */
THREAD_PRIORITY + 1, 10);
if (result == RT_EOK) /* 如果返回正确,启动线程2 */
rt_thread_startup(&thread2);
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
return 0;
}
示例4: thread_same_priority_init
rt_err_t thread_same_priority_init()
{
rt_err_t result;
result = rt_thread_init(&thread1,
"t1",
thread1_entry, RT_NULL,
&thread1_stack[0], sizeof(thread1_stack),
THREAD_PRIORITY, 10);
if (result == RT_EOK)
rt_thread_startup(&thread1);
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
result = rt_thread_init(&thread2,
"t2",
thread2_entry, RT_NULL,
&thread2_stack[0], sizeof(thread2_stack),
THREAD_PRIORITY, 5);
if (result == RT_EOK)
rt_thread_startup(&thread2);
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
return result;
}
示例5: rt_application_init
int rt_application_init()
{
rt_thread_t init_thread;
rt_err_t result;
/* 初始化静态互斥量 */
result = rt_mutex_init(&static_mutex, "smutex", RT_IPC_FLAG_FIFO);
if (result != RT_EOK)
{
rt_kprintf("init static mutex failed.\n");
return -1;
}
/* 创建一个动态互斥量 */
dynamic_mutex = rt_mutex_create("dmutex", RT_IPC_FLAG_FIFO);
if (dynamic_mutex == RT_NULL)
{
rt_kprintf("create dynamic mutex failed.\n");
return -1;
}
#if (RT_THREAD_PRIORITY_MAX == 32)
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, 8, 20);
#else
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,
2048, 80, 20);
#endif
if (init_thread != RT_NULL)
rt_thread_startup(init_thread);
rt_thread_init(&thread1,
"thread1",
rt_thread_entry1,
RT_NULL,
&thread1_stack[0],
sizeof(thread1_stack),11,5);
rt_thread_startup(&thread1);
rt_thread_init(&thread2,
"thread2",
rt_thread_entry2,
RT_NULL,
&thread2_stack[0],
sizeof(thread2_stack),10,5);
rt_thread_startup(&thread2);
return 0;
}
示例6: jffs2_start_garbage_collect_thread
void
jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
{
struct super_block *sb=OFNI_BS_2SFFJ(c);
cyg_mtab_entry *mte;
int result;
RT_ASSERT(c);
//RT_ASSERT(!sb->s_gc_thread_handle);
mte=(cyg_dir *) sb->s_root;
RT_ASSERT(mte);
rt_event_init(&sb->s_gc_thread_flags, "gc_event", RT_IPC_FLAG_FIFO);
rt_mutex_init(&sb->s_lock, "gc_mutex", RT_IPC_FLAG_FIFO);
// rt_mutex_init(&mte->fs->syncmode, "fs_lock", RT_IPC_FLAG_FIFO);
D1(printk("jffs2_start_garbage_collect_thread\n"));
/* Start the thread. Doesn't matter if it fails -- it's only an
* optimisation anyway */
result = rt_thread_init(&sb->s_gc_thread,
"jffs2_gc_thread",
jffs2_garbage_collect_thread,
(void *)c,
(void*)sb->s_gc_thread_stack,
sizeof(sb->s_gc_thread_stack),
CYGNUM_JFFS2_GC_THREAD_PRIORITY,
CYGNUM_JFFS2_GC_THREAD_TICKS
);
if (result != RT_EOK) {
rt_thread_startup(&sb->s_gc_thread);
/* how to deal with the following filed? */
/* sb->s_gc_thread_handle; */
}
}
示例7: rt_usb_vcom_init
static void rt_usb_vcom_init(struct ufunction *func)
{
rt_err_t result = RT_EOK;
struct serial_configure config;
struct vcom *data = (struct vcom*)func->user_data;
/* initialize ring buffer */
rt_ringbuffer_init(&data->rx_ringbuffer, data->rx_rbp, CDC_RX_BUFSIZE);
config.baud_rate = BAUD_RATE_115200;
config.bit_order = BIT_ORDER_LSB;
config.data_bits = DATA_BITS_8;
config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL;
data->serial.ops = &usb_vcom_ops;
data->serial.int_rx = &data->vcom_int_rx;
data->serial.config = config;
/* register vcom device */
rt_hw_serial_register(&data->serial, VCOM_DEVICE,
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_INT_TX,
func);
/* create an vcom message queue */
rt_mq_init(&vcom_tx_thread_mq, "vcomq", vcom_tx_thread_mq_pool, VCOM_MQ_MSG_SZ,
sizeof(vcom_tx_thread_mq_pool), RT_IPC_FLAG_FIFO);
/* init usb device thread */
rt_thread_init(&vcom_thread, "vcom", vcom_tx_thread_entry, RT_NULL,
vcom_thread_stack, 512, 8, 20);
result = rt_thread_startup(&vcom_thread);
RT_ASSERT(result == RT_EOK);
}
示例8:
void *ClockChrono_Write(void *args)
{
RT_TASK *mytask;
Display_tDest receiver;
MenageHmsh_tChain11 chain;
mqd_t Screen;
struct mq_attr sc_attrs = { MAX_MSGS, 12, 0, 0 };
if (!(mytask = rt_thread_init(nam2num("WRITE"), 1, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT TASK ClockChronoWrite\n");
exit(1);
}
Screen = mq_open("SCREEN", O_WRONLY | O_CREAT | O_NONBLOCK, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, &sc_attrs);
printf("INIT TASK ClockChronoWrite %p.\n", mytask);
mlockall(MCL_CURRENT | MCL_FUTURE);
while(1) {
Display_Get(&chain, &receiver);
if (chain.chain[1] == 'e') {
goto end;
}
if (!hide && !Pause) {
mq_send(Screen, chain.chain, 12, 0);
}
}
end:
mq_close(Screen);
rt_task_delete(mytask);
printf("END TASK ClockChronoWrite %p.\n", mytask);
return 0;
}
示例9: rt_system_timer_thread_init
/**
* @ingroup SystemInit
*
* This function will initialize system timer thread
*/
void rt_system_timer_thread_init(void)
{
#ifdef RT_USING_TIMER_SOFT
int i;
for (i = 0;
i < sizeof(rt_soft_timer_list)/sizeof(rt_soft_timer_list[0]);
i++)
{
rt_list_init(rt_soft_timer_list+i);
}
/* start software timer thread */
rt_thread_init(&timer_thread,
"timer",
rt_thread_timer_entry,
RT_NULL,
&timer_thread_stack[0],
sizeof(timer_thread_stack),
RT_TIMER_THREAD_PRIO,
10);
/* startup */
rt_thread_startup(&timer_thread);
#endif
}
示例10: rt_application_init
int rt_application_init()
{
rt_thread_init(&user_thread, "user1", user_thread_entry, RT_NULL,
user_thread_stack, sizeof(user_thread_stack), 21, 20);
rt_thread_startup(&user_thread);
return 0;
}
示例11: bfun
static void bfun(int t)
{
RT_TASK *mytask;
RT_MSGQ *smbx, *rmbx[NTASKS];
int msg[MAXSIZ + 1], mtype, i, n;
mytask = rt_thread_init(nam2num("BFUN"), 1, 0, SCHED_FIFO, 0xF);
smbx = rt_msgq_init(nam2num("SMSG"), NTASKS, 0);
for (i = 0; i < NTASKS; i++) {
char mname[6] = "RMBX";
mname[4] = i + '0';
mname[5] = 0;
rmbx[i] = rt_msgq_init(nam2num(mname), 1, 0);
}
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
while (!end) {
rt_msg_receive(smbx, msg, sizeof(msg), &mtype);
n = 0;
for (i = 1; i < MAXSIZ; i++) {
n += msg[i];
}
if (msg[MAXSIZ] != n) {
rt_printk("SERVER RECEIVED AN UNKNOWN MSG.\n");
goto prem;
}
msg[1] = 0xFFFFFFFF;
rt_msg_send(rmbx[msg[0]], msg, 2*sizeof(int), 1);
}
prem:
rt_make_soft_real_time();
rt_task_delete(mytask);
printf("SERVER TASK ENDS.\n");
}
示例12: main
int main(void)
{
RT_TASK *task;
signal(SIGTERM, catch_signal);
signal(SIGINT, catch_signal);
if (!(task = rt_thread_init(nam2num("SWITCH"), 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT SWITCH TASK SIGNAL\n");
exit(1);
}
start_rt_timer(0);
rt_request_signal(SWITCH_SIGNAL, switch_handler);
rt_task_signal_handler(task, (void *)SWITCH_SIGNAL);
rt_make_hard_real_time();
while (!end) {
rt_sleep(nano2count(PERIOD));
}
rt_task_signal_handler(task, NULL);
rt_release_signal(SWITCH_SIGNAL, task);
rt_make_soft_real_time();
stop_rt_timer();
rt_task_delete(task);
return 0;
}
示例13: signal_func
int signal_func(void *param)
{
RT_TASK *rt_signal;
//TODO: RTIME sampling;
int value = 0;
int rval = 0;
char name[8];
t_info *t = param;
snprintf(name, 8, "S_%c", t->id);
printf("%s\n", name);
rt_signal = rt_thread_init(nam2num(name), 0, 0, SCHED_FIFO, CPUMAP);
if (!rt_signal) {
printf("Could not init real time signal %c\n", t->id);
rval = -ENODEV;
goto exit;
}
rt_task_make_periodic(rt_signal, rt_get_time() + t->period +
t->delay, t->period);
while (!finish) {
value = !value;
printf("[%Ld] signal %c now in %s.\n",
rt_get_time_ns(),
t->id,
value ? "up" : "down");
rt_task_wait_period();
}
rt_task_delete(rt_signal);
exit:
pthread_exit(NULL);
return rval;
}
示例14: tc_start
void tc_start(const char* tc_prefix)
{
rt_err_t result;
/* tesecase prefix is null */
if (tc_prefix == RT_NULL)
{
rt_kprintf("TestCase Usage: tc_start(prefix)\n\n");
rt_kprintf("list_tc() can list all testcases.\n");
return ;
}
/* init tc thread */
if (_tc_stat & TC_STAT_RUNNING)
{
/* stop old tc thread */
tc_stop();
}
rt_memset(_tc_prefix, 0, sizeof(_tc_prefix));
rt_snprintf(_tc_prefix, sizeof(_tc_prefix), "_tc_%s", tc_prefix);
result = rt_thread_init(&_tc_thread, "tc",
tc_thread_entry, RT_NULL,
&_tc_stack[0], sizeof(_tc_stack),
TC_PRIORITY - 3, 5);
/* set tc stat */
_tc_stat = TC_STAT_RUNNING | TC_STAT_FAILED;
if (result == RT_EOK)
rt_thread_startup(&_tc_thread);
}
示例15: main
int main(void)
{
RT_TASK *Main_Task;
long msg;
if (!(Main_Task = rt_thread_init(nam2num("MNTSK"), 10, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT MAIN TASK\n");
exit(1);
}
if (!(hard_timer_running = rt_is_hard_timer_running())) {
start_rt_timer(0);
}
barrier = rt_sem_init(nam2num("PREMS"), 4);
latency_thread = rt_thread_create(latency_fun, NULL, 0);
fast_thread = rt_thread_create(fast_fun, NULL, 0);
slow_thread = rt_thread_create(slow_fun, NULL, 0);
start = rt_get_time() + nano2count(200000000);
rt_sem_wait_barrier(barrier);
rt_receive(0, &msg);
end = 1;
rt_sem_wait_barrier(barrier);
rt_thread_join(latency_thread);
rt_thread_join(fast_thread);
rt_thread_join(slow_thread);
if (!hard_timer_running) {
stop_rt_timer();
}
rt_sem_delete(barrier);
rt_thread_delete(Main_Task);
return 0;
}