MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / list_sem

Function list_sem

components/finsh/cmd.c:289–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287
288#ifdef RT_USING_SEMAPHORE
289long 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 }

Callers 2

ifFunction · 0.85
cmd_listFunction · 0.85

Calls 9

rt_kprintfFunction · 0.85
rt_list_isemptyFunction · 0.85
rt_list_lenFunction · 0.85
rt_susp_list_printFunction · 0.85
list_find_initFunction · 0.70
object_splitFunction · 0.70
list_get_nextFunction · 0.70
rt_spin_lock_irqsaveFunction · 0.50

Tested by

no test coverage detected