| 694 | |
| 695 | #ifdef RT_USING_MEMPOOL |
| 696 | long list_mempool(void) |
| 697 | { |
| 698 | rt_base_t level; |
| 699 | list_get_next_t find_arg; |
| 700 | struct rt_object_information *info; |
| 701 | rt_list_t *obj_list[LIST_FIND_OBJ_NR]; |
| 702 | rt_list_t *next = (rt_list_t *)RT_NULL; |
| 703 | |
| 704 | int maxlen; |
| 705 | const char *item_title = "mempool"; |
| 706 | |
| 707 | list_find_init(&find_arg, RT_Object_Class_MemPool, obj_list, sizeof(obj_list) / sizeof(obj_list[0])); |
| 708 | info = rt_list_entry(find_arg.list, struct rt_object_information, object_list); |
| 709 | |
| 710 | maxlen = RT_NAME_MAX; |
| 711 | |
| 712 | rt_kprintf("%-*.*s block total free suspend thread\n", maxlen, maxlen, item_title); |
| 713 | object_split(maxlen); |
| 714 | rt_kprintf(" ---- ---- ---- --------------\n"); |
| 715 | do |
| 716 | { |
| 717 | next = list_get_next(next, &find_arg); |
| 718 | { |
| 719 | int i; |
| 720 | for (i = 0; i < find_arg.nr_out; i++) |
| 721 | { |
| 722 | struct rt_object *obj; |
| 723 | struct rt_mempool *mp; |
| 724 | int suspend_thread_count; |
| 725 | rt_list_t *node; |
| 726 | |
| 727 | obj = rt_list_entry(obj_list[i], struct rt_object, list); |
| 728 | level = rt_spin_lock_irqsave(&info->spinlock); |
| 729 | if ((obj->type & ~RT_Object_Class_Static) != find_arg.type) |
| 730 | { |
| 731 | rt_spin_unlock_irqrestore(&info->spinlock, level); |
| 732 | continue; |
| 733 | } |
| 734 | |
| 735 | rt_spin_unlock_irqrestore(&info->spinlock, level); |
| 736 | |
| 737 | mp = (struct rt_mempool *)obj; |
| 738 | |
| 739 | suspend_thread_count = 0; |
| 740 | rt_list_for_each(node, &mp->suspend_thread) |
| 741 | { |
| 742 | suspend_thread_count++; |
| 743 | } |
| 744 | |
| 745 | if (suspend_thread_count > 0) |
| 746 | { |
| 747 | rt_kprintf("%-*.*s %04d %04d %04d %d:", |
| 748 | maxlen, RT_NAME_MAX, |
| 749 | mp->parent.name, |
| 750 | mp->block_size, |
| 751 | mp->block_total_count, |
| 752 | mp->block_free_count, |
| 753 | suspend_thread_count); |
no test coverage detected