本文整理汇总了C++中rt_thread_init函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_thread_init函数的具体用法?C++ rt_thread_init怎么用?C++ rt_thread_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_thread_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:haitao52198,项目名称:HD-Elastos,代码行数:35,代码来源:ethernetif.c
示例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;
}
开发者ID:304471720,项目名称:rt-thread,代码行数:28,代码来源:application.c
示例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;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:26,代码来源:thread_static_simple.c
示例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;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:26,代码来源:thread_same_priority.c
示例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;
}
开发者ID:15863118785,项目名称:realtouch-stm32f4,代码行数:52,代码来源:application.c
示例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; */
}
}
开发者ID:634351070,项目名称:rt-thread,代码行数:35,代码来源:gcthread.c
示例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);
}
开发者ID:cedar-renjun,项目名称:air-conditioning-assistant,代码行数:35,代码来源:cdc_vcom.c
示例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;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:33,代码来源:clock.c
示例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
}
开发者ID:KNCheung,项目名称:AlarmClockBeta,代码行数:31,代码来源:timer.c
示例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;
}
开发者ID:304471720,项目名称:rt-thread,代码行数:7,代码来源:application.c
示例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");
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:35,代码来源:uptestmsg.c
示例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;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:30,代码来源:user.c
示例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;
}
开发者ID:nosnilwar,项目名称:rtai-raw-gov-3.9.1,代码行数:34,代码来源:multiple_tasks.c
示例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);
}
开发者ID:bobo8909,项目名称:RTT,代码行数:33,代码来源:tc_comm.c
示例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;
}
开发者ID:ArcEye,项目名称:3.4.55-rtai,代码行数:32,代码来源:preempt.c
示例16: abs
static void *fast_fun(void *arg)
{
int jit, period;
RTIME expected;
if (!(Fast_Task = rt_thread_init(nam2num("FSTSK"), 2, 0, SCHED_FIFO, CPUMAP))) {
printf("CANNOT INIT FAST TASK\n");
exit(1);
}
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
rt_sem_wait_barrier(barrier);
period = nano2count(FASTMUL*TICK_TIME);
expected = start + 6*nano2count(TICK_TIME);
rt_task_make_periodic(Fast_Task, expected, period);
while (!end) {
jit = abs(count2nano(rt_get_time() - expected));
if (jit > fastjit) {
fastjit = jit;
}
rt_busy_sleep((FASTMUL*TICK_TIME*USEDFRAC)/100);
expected += period;
END("FE\n");
rt_task_wait_period();
BEGIN("FB\n");
}
rt_sem_wait_barrier(barrier);
rt_make_soft_real_time();
rt_thread_delete(Fast_Task);
return 0;
}
开发者ID:ArcEye,项目名称:3.4.55-rtai,代码行数:32,代码来源:preempt.c
示例17: RS485_init
/*RS485设备初始化*/
void RS485_init( void )
{
//rt_sem_init( &sem_RS485, "sem_RS485", 0, 0 );
rt_mq_init( &mq_RS485, "mq_RS485", &RS485_rawinfo[0], 128 - sizeof( void* ), RS485_RAWINFO_SIZE, RT_IPC_FLAG_FIFO );
dev_RS485.type = RT_Device_Class_Char;
dev_RS485.init = dev_RS485_init;
dev_RS485.open = dev_RS485_open;
dev_RS485.close = dev_RS485_close;
dev_RS485.read = dev_RS485_read;
dev_RS485.write = dev_RS485_write;
dev_RS485.control = dev_RS485_control;
rt_device_register( &dev_RS485, "RS485", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE );
rt_device_init( &dev_RS485 );
Cam_Device_init( );
rt_thread_init( &thread_RS485,
"RS485",
rt_thread_entry_RS485,
RT_NULL,
&thread_RS485_stack[0],
sizeof( thread_RS485_stack ), 9, 5 );
rt_thread_startup( &thread_RS485 );
}
开发者ID:mildrock,项目名称:705_1,代码行数:26,代码来源:rs485.c
示例18: main
int main(void)
{
int i, srq, count = 0, nextcount = 0, repeat;
rt_thread_init(nam2num("MNTSK"), 100, 0, SCHED_FIFO, 0x1);
rt_printk("\nTESTING THE SCHEDULER WITH SRQs [%d LOOPs].\n", LOOPS);
repeat = 1000000000LL/((long long)DELAY*(long long)PRINT_FREQ);
srq = rtai_open_srq(0xcacca);
start_rt_timer(0);
rt_grow_and_lock_stack(100000);
#ifdef MAKE_HARD
MAKE_HARD();
#endif
for (i = 0; i < LOOPS; i++) {
rtai_srq(srq, (unsigned long)nano2count(DELAY));
if (++count > nextcount) {
nextcount += repeat;
rt_printk(">>> %d.\n", nextcount);
}
}
rt_make_soft_real_time();
stop_rt_timer();
rt_task_delete(NULL);
rt_printk("END SCHEDULER TEST WITH SRQs.\n\n");
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:28,代码来源:display.c
示例19: rt_application_init
int rt_application_init()
{
rt_thread_t init_thread;
rt_err_t result;
/* init led thread */
result = rt_thread_init(&led_thread, "led", led_thread_entry, RT_NULL, (rt_uint8_t*)&led_stack[0], sizeof(led_stack), 20, 5);
if (result == RT_EOK)
{
rt_thread_startup(&led_thread);
}
#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);
return 0;
}
开发者ID:realrealrealman,项目名称:frey-gps-terminal,代码行数:28,代码来源:application.c
示例20:
void *CommandClock_task(void *args)
{
RT_TASK *mytask;
unsigned long command;
char R = 'R';
int ackn = 0;
RT_TASK *get = (RT_TASK *)0, *put = (RT_TASK *)0, *task;
if (!(mytask = rt_thread_init(nam2num("CLKTSK"), 1, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT TASK CommandClock_task\n");
exit(1);
}
printf("INIT TASK CommandClock_task %p.\n", mytask);
mlockall(MCL_CURRENT | MCL_FUTURE);
Clockstatus = stopped;
while (ackn != ('a' + 'b')) {
task = rt_receive((RT_TASK *)0, &command);
switch (command) {
case 'b':
get = task;
ackn += command;
break;
case 'a':
put = task;
ackn += command;
break;
}
}
rt_return(put, command);
rt_return(get, command);
while(1) {
switch (Clockstatus) {
case stopped:
rt_receive(put, &command);
if (command == 'R') {
Clockstatus = running;
}
break;
case running:
if (rt_receive_if(put, &command)) {
if (command == 'T') {
Clockstatus = stopped;
}
} else {
command = R;
}
break;
}
rt_send(get, command);
if (command == 'F') {
goto end;
}
}
end:
rt_task_delete(mytask);
printf("END TASK CommandClock_task %p.\n", mytask);
return 0;
}
开发者ID:ArcEye,项目名称:3.4.55-rtai,代码行数:60,代码来源:cmdclk.c
注:本文中的rt_thread_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论