Merge pull request #4875 from mysterywolf/fifo
[example] replace RT_IPC_FLAG_FIFO with RT_IPC_FLAG_PRIO
This commit is contained in:
commit
ed5612d16f
|
@ -83,7 +83,7 @@ static void thread3_entry(void *param)
|
||||||
int event_simple_init()
|
int event_simple_init()
|
||||||
{
|
{
|
||||||
/* 初始化事件对象 */
|
/* 初始化事件对象 */
|
||||||
rt_event_init(&event, "event", RT_IPC_FLAG_FIFO);
|
rt_event_init(&event, "event", RT_IPC_FLAG_PRIO);
|
||||||
|
|
||||||
/* 创建线程1 */
|
/* 创建线程1 */
|
||||||
tid1 = rt_thread_create("t1",
|
tid1 = rt_thread_create("t1",
|
||||||
|
|
|
@ -82,7 +82,7 @@ int mbox_send_wait_init()
|
||||||
"mbt", /* 名称是mbt */
|
"mbt", /* 名称是mbt */
|
||||||
&mb_pool[0], /* 邮箱用到的内存池是mb_pool */
|
&mb_pool[0], /* 邮箱用到的内存池是mb_pool */
|
||||||
sizeof(mb_pool)/4, /* 大小是mb_pool大小除以4,因为一封邮件的大小是4字节 */
|
sizeof(mb_pool)/4, /* 大小是mb_pool大小除以4,因为一封邮件的大小是4字节 */
|
||||||
RT_IPC_FLAG_FIFO); /* 采用FIFO方式进行线程等待 */
|
RT_IPC_FLAG_PRIO); /* 采用PRIO方式进行线程等待 */
|
||||||
|
|
||||||
/* 创建线程1 */
|
/* 创建线程1 */
|
||||||
tid1 = rt_thread_create("t1",
|
tid1 = rt_thread_create("t1",
|
||||||
|
|
|
@ -80,7 +80,7 @@ int mbox_simple_init()
|
||||||
"mbt", /* 名称是mbt */
|
"mbt", /* 名称是mbt */
|
||||||
&mb_pool[0], /* 邮箱用到的内存池是mb_pool */
|
&mb_pool[0], /* 邮箱用到的内存池是mb_pool */
|
||||||
sizeof(mb_pool)/4, /* 大小是mb_pool大小除以4,因为一封邮件的大小是4字节 */
|
sizeof(mb_pool)/4, /* 大小是mb_pool大小除以4,因为一封邮件的大小是4字节 */
|
||||||
RT_IPC_FLAG_FIFO); /* 采用FIFO方式进行线程等待 */
|
RT_IPC_FLAG_PRIO); /* 采用PRIO方式进行线程等待 */
|
||||||
|
|
||||||
/* 创建线程1 */
|
/* 创建线程1 */
|
||||||
tid1 = rt_thread_create("t1",
|
tid1 = rt_thread_create("t1",
|
||||||
|
|
|
@ -98,7 +98,7 @@ int messageq_simple_init()
|
||||||
&msg_pool[0], /* 内存池指向msg_pool */
|
&msg_pool[0], /* 内存池指向msg_pool */
|
||||||
128 - sizeof(void*), /* 每个消息的大小是 128 - void* */
|
128 - sizeof(void*), /* 每个消息的大小是 128 - void* */
|
||||||
sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */
|
sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */
|
||||||
RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
|
RT_IPC_FLAG_PRIO); /* 如果有多个线程等待,按照优先级由高到低的方法分配消息 */
|
||||||
|
|
||||||
/* 创建线程1 */
|
/* 创建线程1 */
|
||||||
tid1 = rt_thread_create("t1",
|
tid1 = rt_thread_create("t1",
|
||||||
|
|
|
@ -281,7 +281,7 @@ static void thread29_entry(void* parameter)
|
||||||
static int mutex_simple_init()
|
static int mutex_simple_init()
|
||||||
{
|
{
|
||||||
/* 创建互斥锁 */
|
/* 创建互斥锁 */
|
||||||
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_FIFO);
|
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_PRIO);
|
||||||
if (mutex == RT_NULL)
|
if (mutex == RT_NULL)
|
||||||
{
|
{
|
||||||
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
||||||
|
|
|
@ -87,7 +87,7 @@ static void thread3_entry(void* parameter)
|
||||||
int mutex_simple_init()
|
int mutex_simple_init()
|
||||||
{
|
{
|
||||||
/* 创建互斥锁 */
|
/* 创建互斥锁 */
|
||||||
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_FIFO);
|
mutex = rt_mutex_create("mutex", RT_IPC_FLAG_PRIO);
|
||||||
if (mutex == RT_NULL)
|
if (mutex == RT_NULL)
|
||||||
{
|
{
|
||||||
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
||||||
|
|
|
@ -209,7 +209,7 @@ int semaphore_buffer_worker_init()
|
||||||
rb_init(&working_rb, working_buffer, BUFFER_SIZE);
|
rb_init(&working_rb, working_buffer, BUFFER_SIZE);
|
||||||
|
|
||||||
/* 创建信号量 */
|
/* 创建信号量 */
|
||||||
sem = rt_sem_create("sem", 1, RT_IPC_FLAG_FIFO);
|
sem = rt_sem_create("sem", 1, RT_IPC_FLAG_PRIO);
|
||||||
if (sem == RT_NULL)
|
if (sem == RT_NULL)
|
||||||
{
|
{
|
||||||
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
||||||
|
|
|
@ -78,7 +78,7 @@ static void thread_entry(void* parameter)
|
||||||
int semaphore_dynamic_init()
|
int semaphore_dynamic_init()
|
||||||
{
|
{
|
||||||
/* 创建一个信号量,初始值是0 */
|
/* 创建一个信号量,初始值是0 */
|
||||||
sem = rt_sem_create("sem", 0, RT_IPC_FLAG_FIFO);
|
sem = rt_sem_create("sem", 0, RT_IPC_FLAG_PRIO);
|
||||||
if (sem == RT_NULL)
|
if (sem == RT_NULL)
|
||||||
{
|
{
|
||||||
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
||||||
|
|
|
@ -98,9 +98,9 @@ void consumer_thread_entry(void* parameter)
|
||||||
int semaphore_producer_consumer_init()
|
int semaphore_producer_consumer_init()
|
||||||
{
|
{
|
||||||
/* 初始化3个信号量 */
|
/* 初始化3个信号量 */
|
||||||
rt_sem_init(&sem_lock , "lock", 1, RT_IPC_FLAG_FIFO);
|
rt_sem_init(&sem_lock , "lock", 1, RT_IPC_FLAG_PRIO);
|
||||||
rt_sem_init(&sem_empty, "empty", MAXSEM, RT_IPC_FLAG_FIFO);
|
rt_sem_init(&sem_empty, "empty", MAXSEM, RT_IPC_FLAG_PRIO);
|
||||||
rt_sem_init(&sem_full , "full", 0, RT_IPC_FLAG_FIFO);
|
rt_sem_init(&sem_full , "full", 0, RT_IPC_FLAG_PRIO);
|
||||||
|
|
||||||
/* 创建线程1 */
|
/* 创建线程1 */
|
||||||
producer_tid = rt_thread_create("producer",
|
producer_tid = rt_thread_create("producer",
|
||||||
|
|
|
@ -81,7 +81,7 @@ int semaphore_static_init(void)
|
||||||
rt_err_t result;
|
rt_err_t result;
|
||||||
|
|
||||||
/* 初始化信号量,初始值是0 */
|
/* 初始化信号量,初始值是0 */
|
||||||
result = rt_sem_init(&sem, "sem", 0, RT_IPC_FLAG_FIFO);
|
result = rt_sem_init(&sem, "sem", 0, RT_IPC_FLAG_PRIO);
|
||||||
if (result != RT_EOK)
|
if (result != RT_EOK)
|
||||||
{
|
{
|
||||||
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
tc_stat(TC_STAT_END | TC_STAT_FAILED);
|
||||||
|
|
|
@ -35,7 +35,7 @@ void tc_thread_entry(void* parameter)
|
||||||
struct finsh_syscall* index;
|
struct finsh_syscall* index;
|
||||||
|
|
||||||
/* create tc semaphore */
|
/* create tc semaphore */
|
||||||
rt_sem_init(&_tc_sem, "tc", 0, RT_IPC_FLAG_FIFO);
|
rt_sem_init(&_tc_sem, "tc", 0, RT_IPC_FLAG_PRIO);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
|
for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index))
|
||||||
|
|
|
@ -73,7 +73,7 @@ int timer_timeout_init()
|
||||||
&msg_pool[0], /* 内存池指向msg_pool */
|
&msg_pool[0], /* 内存池指向msg_pool */
|
||||||
128 - sizeof(void*), /* 每个消息的大小是 128 - void* */
|
128 - sizeof(void*), /* 每个消息的大小是 128 - void* */
|
||||||
sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */
|
sizeof(msg_pool), /* 内存池的大小是msg_pool的大小 */
|
||||||
RT_IPC_FLAG_FIFO); /* 如果有多个线程等待,按照先来先得到的方法分配消息 */
|
RT_IPC_FLAG_PRIO); /* 如果有多个线程等待,按照优先级由高到低的方法分配消息 */
|
||||||
|
|
||||||
/* 创建线程 */
|
/* 创建线程 */
|
||||||
tid = rt_thread_create("t",
|
tid = rt_thread_create("t",
|
||||||
|
|
|
@ -61,7 +61,7 @@ static int wakeup_app(void)
|
||||||
{
|
{
|
||||||
rt_thread_t tid;
|
rt_thread_t tid;
|
||||||
|
|
||||||
wakeup_event = rt_event_create("wakup", RT_IPC_FLAG_FIFO);
|
wakeup_event = rt_event_create("wakup", RT_IPC_FLAG_PRIO);
|
||||||
RT_ASSERT(wakeup_event != RT_NULL);
|
RT_ASSERT(wakeup_event != RT_NULL);
|
||||||
|
|
||||||
tid = rt_thread_create("wakeup_app", wakeup_app_entry, RT_NULL,
|
tid = rt_thread_create("wakeup_app", wakeup_app_entry, RT_NULL,
|
||||||
|
|
Loading…
Reference in New Issue