| 287 | |
| 288 | #ifdef RT_USING_SEMAPHORE |
| 289 | long list_sem(void) |
| 290 | { |
| 291 | rt_base_t level; |
| 292 | list_get_next_t find_arg; |
| 293 | struct rt_object_information *info; |
| 294 | rt_list_t *obj_list[LIST_FIND_OBJ_NR]; |
| 295 | rt_list_t *next = (rt_list_t *)RT_NULL; |
| 296 | |
| 297 | int maxlen; |
| 298 | const char *item_title = "semaphore"; |
| 299 | |
| 300 | list_find_init(&find_arg, RT_Object_Class_Semaphore, obj_list, sizeof(obj_list) / sizeof(obj_list[0])); |
| 301 | info = rt_list_entry(find_arg.list, struct rt_object_information, object_list); |
| 302 | |
| 303 | maxlen = RT_NAME_MAX; |
| 304 | |
| 305 | rt_kprintf("%-*.*s v suspend thread\n", maxlen, maxlen, item_title); |
| 306 | object_split(maxlen); |
| 307 | rt_kprintf(" --- --------------\n"); |
| 308 | |
| 309 | do |
| 310 | { |
| 311 | next = list_get_next(next, &find_arg); |
| 312 | { |
| 313 | int i; |
| 314 | for (i = 0; i < find_arg.nr_out; i++) |
| 315 | { |
| 316 | struct rt_object *obj; |
| 317 | struct rt_semaphore *sem; |
| 318 | |
| 319 | obj = rt_list_entry(obj_list[i], struct rt_object, list); |
| 320 | level = rt_spin_lock_irqsave(&info->spinlock); |
| 321 | if ((obj->type & ~RT_Object_Class_Static) != find_arg.type) |
| 322 | { |
| 323 | rt_spin_unlock_irqrestore(&info->spinlock, level); |
| 324 | continue; |
| 325 | } |
| 326 | rt_spin_unlock_irqrestore(&info->spinlock, level); |
| 327 | |
| 328 | sem = (struct rt_semaphore *)obj; |
| 329 | if (!rt_list_isempty(&sem->parent.suspend_thread)) |
| 330 | { |
| 331 | rt_kprintf("%-*.*s %03d %d:", |
| 332 | maxlen, RT_NAME_MAX, |
| 333 | sem->parent.parent.name, |
| 334 | sem->value, |
| 335 | rt_list_len(&sem->parent.suspend_thread)); |
| 336 | rt_susp_list_print(&(sem->parent.suspend_thread)); |
| 337 | rt_kprintf("\n"); |
| 338 | } |
| 339 | else |
| 340 | { |
| 341 | rt_kprintf("%-*.*s %03d %d\n", |
| 342 | maxlen, RT_NAME_MAX, |
| 343 | sem->parent.parent.name, |
| 344 | sem->value, |
| 345 | rt_list_len(&sem->parent.suspend_thread)); |
| 346 | } |
no test coverage detected