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

Function rt_object_get_pointers

src/object.c:305–333  ·  view source on GitHub ↗

* @brief This function will copy the object pointer of the specified type, * with the maximum size specified by maxlen. * * @param type is the type of object, which can be * RT_Object_Class_Thread/Semaphore/Mutex... etc * * @param pointers is the pointer will be saved to. * * @param maxlen is the maximum number of pointers can be saved. * * @return the copied number of

Source from the content-addressed store, hash-verified

303 * @return the copied number of object pointers.
304 */
305int rt_object_get_pointers(enum rt_object_class_type type, rt_object_t *pointers, int maxlen)
306{
307 int index = 0;
308 rt_base_t level;
309
310 struct rt_object *object;
311 struct rt_list_node *node = RT_NULL;
312 struct rt_object_information *information = RT_NULL;
313
314 if (maxlen <= 0) return 0;
315
316 information = rt_object_get_information(type);
317 if (information == RT_NULL) return 0;
318
319 level = rt_spin_lock_irqsave(&(information->spinlock));
320 /* retrieve pointer of object */
321 rt_list_for_each(node, &(information->object_list))
322 {
323 object = rt_list_entry(node, struct rt_object, list);
324
325 pointers[index] = object;
326 index ++;
327
328 if (index >= maxlen) break;
329 }
330 rt_spin_unlock_irqrestore(&(information->spinlock), level);
331
332 return index;
333}
334RTM_EXPORT(rt_object_get_pointers);
335
336/**

Callers 5

list_processFunction · 0.85
list_sessionFunction · 0.85
list_processgroupFunction · 0.85
dfs_devfs_updateFunction · 0.85

Calls 3

rt_spin_lock_irqsaveFunction · 0.70

Tested by 1