| 421 | |
| 422 | #ifdef RT_USING_MUTEX |
| 423 | long list_mutex(void) |
| 424 | { |
| 425 | rt_base_t level; |
| 426 | list_get_next_t find_arg; |
| 427 | struct rt_object_information *info; |
| 428 | rt_list_t *obj_list[LIST_FIND_OBJ_NR]; |
| 429 | rt_list_t *next = (rt_list_t *)RT_NULL; |
| 430 | |
| 431 | int maxlen; |
| 432 | const char *item_title = "mutex"; |
| 433 | |
| 434 | list_find_init(&find_arg, RT_Object_Class_Mutex, obj_list, sizeof(obj_list) / sizeof(obj_list[0])); |
| 435 | info = rt_list_entry(find_arg.list, struct rt_object_information, object_list); |
| 436 | |
| 437 | maxlen = RT_NAME_MAX; |
| 438 | |
| 439 | rt_kprintf("%-*.*s owner hold priority suspend thread \n", maxlen, maxlen, item_title); |
| 440 | object_split(maxlen); |
| 441 | rt_kprintf(" -------- ---- -------- --------------\n"); |
| 442 | |
| 443 | do |
| 444 | { |
| 445 | next = list_get_next(next, &find_arg); |
| 446 | { |
| 447 | int i; |
| 448 | for (i = 0; i < find_arg.nr_out; i++) |
| 449 | { |
| 450 | struct rt_object *obj; |
| 451 | struct rt_mutex *m; |
| 452 | |
| 453 | obj = rt_list_entry(obj_list[i], struct rt_object, list); |
| 454 | level = rt_spin_lock_irqsave(&info->spinlock); |
| 455 | if ((obj->type & ~RT_Object_Class_Static) != find_arg.type) |
| 456 | { |
| 457 | rt_spin_unlock_irqrestore(&info->spinlock, level); |
| 458 | continue; |
| 459 | } |
| 460 | |
| 461 | rt_spin_unlock_irqrestore(&info->spinlock, level); |
| 462 | |
| 463 | m = (struct rt_mutex *)obj; |
| 464 | if (!rt_list_isempty(&m->parent.suspend_thread)) |
| 465 | { |
| 466 | rt_kprintf("%-*.*s %-8.*s %04d %8d %04d ", |
| 467 | maxlen, RT_NAME_MAX, |
| 468 | m->parent.parent.name, |
| 469 | RT_NAME_MAX, |
| 470 | (m->owner == RT_NULL) ? "(null)" : m->owner->parent.name, |
| 471 | m->hold, |
| 472 | m->priority, |
| 473 | rt_list_len(&m->parent.suspend_thread)); |
| 474 | rt_susp_list_print(&(m->parent.suspend_thread)); |
| 475 | rt_kprintf("\n"); |
| 476 | } |
| 477 | else |
| 478 | { |
| 479 | rt_kprintf("%-*.*s %-8.*s %04d %8d %04d\n", |
| 480 | maxlen, RT_NAME_MAX, |
no test coverage detected