FIX: Removed suspend_thread_count.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@317 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
f4af7e8401
commit
f8f7a5f510
43
finsh/cmd.c
43
finsh/cmd.c
|
@ -27,7 +27,26 @@
|
|||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "finsh.h"
|
||||
#include "finsh.h"
|
||||
|
||||
// Copy from kservice.h because we can not use it out of the kernel.
|
||||
// Ugly. Should let kservice.h avaliable for applications?
|
||||
rt_inline int rt_list_isempty(const rt_list_t *l)
|
||||
{
|
||||
return l->next == l;
|
||||
}
|
||||
|
||||
rt_inline unsigned int rt_list_len(const rt_list_t *l)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
const rt_list_t *p = l;
|
||||
while( p->next != l )
|
||||
{
|
||||
p = p->next;
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
long hello()
|
||||
{
|
||||
|
@ -109,16 +128,16 @@ int list_sem()
|
|||
rt_kprintf("-------- --- --------------\n");
|
||||
for (node = list->next; node != list; node = node->next)
|
||||
{
|
||||
sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list));
|
||||
if (sem->parent.suspend_thread_count != 0)
|
||||
sem = (struct rt_semaphore*)(rt_list_entry(node, struct rt_object, list));
|
||||
if( !rt_list_isempty(&sem->parent.suspend_thread) )
|
||||
{
|
||||
rt_kprintf("%-8s %03d %d:", sem->parent.parent.name, sem->value, sem->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s %03d %d:", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread) );
|
||||
show_wait_queue(&(sem->parent.suspend_thread));
|
||||
rt_kprintf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("%-8s %03d %d\n", sem->parent.parent.name, sem->value, sem->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s %03d %d\n", sem->parent.parent.name, sem->value, rt_list_len(&sem->parent.suspend_thread));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +159,7 @@ int list_event()
|
|||
for (node = list->next; node != list; node = node->next)
|
||||
{
|
||||
e = (struct rt_event*)(rt_list_entry(node, struct rt_object, list));
|
||||
rt_kprintf("%-8s 0x%08x %03d\n", e->parent.parent.name, e->set, e->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s 0x%08x %03d\n", e->parent.parent.name, e->set, rt_list_len(&e->parent.suspend_thread));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -161,7 +180,7 @@ int list_mutex()
|
|||
for (node = list->next; node != list; node = node->next)
|
||||
{
|
||||
m = (struct rt_mutex*)(rt_list_entry(node, struct rt_object, list));
|
||||
rt_kprintf("%-8s %-8s %04d %d\n", m->parent.parent.name, m->owner->name, m->hold, m->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s %-8s %04d %d\n", m->parent.parent.name, m->owner->name, m->hold, rt_list_len(&m->parent.suspend_thread));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -181,16 +200,16 @@ int list_mailbox()
|
|||
rt_kprintf("-------- ---- ---- --------------\n");
|
||||
for (node = list->next; node != list; node = node->next)
|
||||
{
|
||||
m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list));
|
||||
if (m->parent.suspend_thread_count != 0)
|
||||
m = (struct rt_mailbox*)(rt_list_entry(node, struct rt_object, list));
|
||||
if( !rt_list_isempty(&m->parent.suspend_thread) )
|
||||
{
|
||||
rt_kprintf("%-8s %04d %04d %d:", m->parent.parent.name, m->entry, m->size, m->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s %04d %04d %d:", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread));
|
||||
show_wait_queue(&(m->parent.suspend_thread));
|
||||
rt_kprintf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("%-8s %04d %04d %d\n", m->parent.parent.name, m->entry, m->size, m->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s %04d %04d %d\n", m->parent.parent.name, m->entry, m->size, rt_list_len(&m->parent.suspend_thread));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +231,7 @@ int list_msgqueue()
|
|||
for (node = list->next; node != list; node = node->next)
|
||||
{
|
||||
m = (struct rt_messagequeue*)(rt_list_entry(node, struct rt_object, list));
|
||||
rt_kprintf("%-8s %04d %d\n", m->parent.parent.name, m->entry, m->parent.suspend_thread_count);
|
||||
rt_kprintf("%-8s %04d %d\n", m->parent.parent.name, m->entry, rt_list_len(&m->parent.suspend_thread));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -387,7 +387,6 @@ struct rt_ipc_object
|
|||
struct rt_object parent;
|
||||
|
||||
rt_list_t suspend_thread; /* threads pended on this resource. */
|
||||
rt_uint32_t suspend_thread_count; /* numbers of thread pended on this resource. */
|
||||
};
|
||||
|
||||
#ifdef RT_USING_SEMAPHORE
|
||||
|
|
37
src/ipc.c
37
src/ipc.c
|
@ -62,7 +62,6 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
|
|||
{
|
||||
/* init ipc object */
|
||||
rt_list_init(&(ipc->suspend_thread));
|
||||
ipc->suspend_thread_count = 0;
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
@ -80,7 +79,6 @@ rt_inline rt_err_t rt_ipc_object_suspend(struct rt_ipc_object *ipc, struct rt_th
|
|||
{
|
||||
/* suspend thread */
|
||||
rt_thread_suspend(thread);
|
||||
ipc->suspend_thread_count ++;
|
||||
|
||||
switch (ipc->parent.flag)
|
||||
{
|
||||
|
@ -141,9 +139,6 @@ rt_inline rt_err_t rt_ipc_object_resume(struct rt_ipc_object* ipc)
|
|||
/* resume it */
|
||||
rt_thread_resume(thread);
|
||||
|
||||
/* decrease suspended thread count */
|
||||
ipc->suspend_thread_count --;
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
@ -175,10 +170,7 @@ rt_inline rt_err_t rt_ipc_object_resume_all(struct rt_ipc_object* ipc)
|
|||
* In rt_thread_resume function, it will remove current thread from
|
||||
* suspend list
|
||||
*/
|
||||
rt_thread_resume(thread);
|
||||
|
||||
/* decrease suspended thread count */
|
||||
ipc->suspend_thread_count --;
|
||||
rt_thread_resume(thread);
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(temp);
|
||||
|
@ -195,9 +187,6 @@ rt_inline void rt_ipc_object_decrease(struct rt_ipc_object* ipc)
|
|||
/* disable interrupt */
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
/* decrease suspended thread count */
|
||||
ipc->suspend_thread_count --;
|
||||
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
|
@ -441,7 +430,7 @@ rt_err_t rt_sem_release(rt_sem_t sem)
|
|||
((struct rt_object*)sem)->name, sem->value);
|
||||
#endif
|
||||
|
||||
if (sem->parent.suspend_thread_count > 0)
|
||||
if ( !rt_list_isempty(&sem->parent.suspend_thread) )
|
||||
{
|
||||
/* resume the suspended thread */
|
||||
rt_ipc_object_resume(&(sem->parent));
|
||||
|
@ -768,8 +757,8 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
|
|||
&(mutex->owner->init_priority));
|
||||
}
|
||||
|
||||
/* wakeup suspended thread */
|
||||
if (mutex->parent.suspend_thread_count > 0)
|
||||
/* wakeup suspended thread */
|
||||
if( !rt_list_isempty(&mutex->parent.suspend_thread) )
|
||||
{
|
||||
/* get thread entry */
|
||||
thread = rt_list_entry(mutex->parent.suspend_thread.next, struct rt_thread, tlist);
|
||||
|
@ -957,8 +946,8 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
|
|||
|
||||
/* set event */
|
||||
event->set |= set;
|
||||
|
||||
if (event->parent.suspend_thread_count > 0)
|
||||
|
||||
if( !rt_list_isempty(&event->parent.suspend_thread) )
|
||||
{
|
||||
/* search thread list to resume thread */
|
||||
n = event->parent.suspend_thread.next;
|
||||
|
@ -1004,8 +993,6 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
|
|||
/* need do a scheduling */
|
||||
need_schedule = RT_TRUE;
|
||||
|
||||
/* decrease suspended thread count */
|
||||
event->parent.suspend_thread_count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1306,8 +1293,8 @@ rt_err_t rt_mb_send (rt_mailbox_t mb, rt_uint32_t value)
|
|||
/* increase message entry */
|
||||
mb->entry ++;
|
||||
|
||||
/* resume suspended thread */
|
||||
if (mb->parent.suspend_thread_count > 0)
|
||||
/* resume suspended thread */
|
||||
if( !rt_list_isempty(&mb->parent.suspend_thread) )
|
||||
{
|
||||
rt_ipc_object_resume(&(mb->parent));
|
||||
|
||||
|
@ -1680,8 +1667,8 @@ rt_err_t rt_mq_send (rt_mq_t mq, void* buffer, rt_size_t size)
|
|||
/* increase message entry */
|
||||
mq->entry ++;
|
||||
|
||||
/* resume suspended thread */
|
||||
if (mq->parent.suspend_thread_count > 0)
|
||||
/* resume suspended thread */
|
||||
if( !rt_list_isempty(&mq->parent.suspend_thread) )
|
||||
{
|
||||
rt_ipc_object_resume(&(mq->parent));
|
||||
|
||||
|
@ -1752,8 +1739,8 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, void* buffer, rt_size_t size)
|
|||
/* increase message entry */
|
||||
mq->entry ++;
|
||||
|
||||
/* resume suspended thread */
|
||||
if (mq->parent.suspend_thread_count > 0)
|
||||
/* resume suspended thread */
|
||||
if( !rt_list_isempty(&mq->parent.suspend_thread) )
|
||||
{
|
||||
rt_ipc_object_resume(&(mq->parent));
|
||||
|
||||
|
|
Loading…
Reference in New Issue