提交 ae674ab3 编写于 作者: M mbbill@gmail.com

Now, lwip is using blocking mailbox.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1473 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 70c03136
#include <rtthread.h> #include <rtthread.h>
#include "lwip/debug.h"
#include "lwip/sys.h" #include "lwip/sys.h"
#include "lwip/opt.h" #include "lwip/opt.h"
#include "lwip/stats.h" #include "lwip/stats.h"
#include "lwip/err.h" #include "lwip/err.h"
#include "arch/sys_arch.h" #include "arch/sys_arch.h"
#include "lwip/debug.h"
#include <string.h> #include <string.h>
...@@ -269,7 +269,6 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int size) ...@@ -269,7 +269,6 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int size)
{ {
struct rt_thread *thread; struct rt_thread *thread;
thread = rt_thread_self(); thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Create mbox: %s \n",thread->name, tname)); LWIP_DEBUGF(SYS_DEBUG, ("%s, Create mbox: %s \n",thread->name, tname));
} }
#endif #endif
...@@ -316,12 +315,12 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg) ...@@ -316,12 +315,12 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg)
thread = rt_thread_self(); thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name, LWIP_DEBUGF(SYS_DEBUG, ("%s, Post mail: %s ,0x%x\n",thread->name,
(*mbo)x->parent.parent.name, (rt_uint32_t)msg)); (*mbox)->parent.parent.name, (rt_uint32_t)msg));
} }
#endif #endif
if (rt_mb_send(*mbox, (rt_uint32_t)msg) != RT_EOK) //rt_mb_send_wait(*mbox, (rt_uint32_t)msg,RT_WAITING_FOREVER);
rt_kprintf("TODO: FIX THIS!! mbox overflow"); rt_mb_send(*mbox, (rt_uint32_t)msg);
return; return;
} }
...@@ -386,7 +385,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) ...@@ -386,7 +385,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
thread = rt_thread_self(); thread = rt_thread_self();
LWIP_DEBUGF(SYS_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name, LWIP_DEBUGF(SYS_DEBUG, ("%s, Fetch mail: %s , 0x%x\n",thread->name,
mbox->parent.parent.name, *(rt_uint32_t **)msg)); (*mbox)->parent.parent.name, *(rt_uint32_t **)msg));
} }
#endif #endif
......
...@@ -1197,6 +1197,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, const char* name, void* msgpool, rt_size_t ...@@ -1197,6 +1197,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, const char* name, void* msgpool, rt_size_t
mb->in_offset = 0; mb->in_offset = 0;
mb->out_offset = 0; mb->out_offset = 0;
/* init an additional list of sender suspend thread */
rt_list_init(&(mb->suspend_sender_thread)); rt_list_init(&(mb->suspend_sender_thread));
return RT_EOK; return RT_EOK;
...@@ -1263,6 +1264,9 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag) ...@@ -1263,6 +1264,9 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag)
mb->in_offset = 0; mb->in_offset = 0;
mb->out_offset = 0; mb->out_offset = 0;
/* init an additional list of sender suspend thread */
rt_list_init(&(mb->suspend_sender_thread));
return mb; return mb;
} }
...@@ -1274,12 +1278,13 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag) ...@@ -1274,12 +1278,13 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag)
* @return the error code * @return the error code
*/ */
rt_err_t rt_mb_delete (rt_mailbox_t mb) rt_err_t rt_mb_delete (rt_mailbox_t mb)
{ {
/* parameter check */ /* parameter check */
RT_ASSERT(mb != RT_NULL); RT_ASSERT(mb != RT_NULL);
/* resume all suspended thread */ /* resume all suspended thread */
rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
/* also resume all mailbox private suspended thread */ /* also resume all mailbox private suspended thread */
rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
...@@ -1576,6 +1581,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, rt_uint8_t cmd, void* arg) ...@@ -1576,6 +1581,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, rt_uint8_t cmd, void* arg)
/* resume all waiting thread */ /* resume all waiting thread */
rt_ipc_list_resume_all(&(mb->parent.suspend_thread)); rt_ipc_list_resume_all(&(mb->parent.suspend_thread));
/* also resume all mailbox private suspended thread */
rt_ipc_list_resume_all(&(mb->suspend_sender_thread));
/* re-init mailbox */ /* re-init mailbox */
mb->entry = 0; mb->entry = 0;
mb->in_offset = 0; mb->in_offset = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册