RT-Thread RTOS  1.0.0
An open source embedded real-time operating system
Kernel Object Management

Data Structures

struct  rt_object
struct  rt_object_information

Defines

#define RT_OBJECT_HOOK_CALL(func, argv)   do { if ((func) != RT_NULL) func argv; } while (0)

Enumerations

enum  rt_object_class_type {
  RT_Object_Class_Thread = 0, RT_Object_Class_Semaphore, RT_Object_Class_Mutex, RT_Object_Class_Event,
  RT_Object_Class_MailBox, RT_Object_Class_MessageQueue, RT_Object_Class_MemPool, RT_Object_Class_Device,
  RT_Object_Class_Timer, RT_Object_Class_Module, RT_Object_Class_Unknown, RT_Object_Class_Static = 0x80
}

Functions

struct rt_object_informationrt_object_get_information (enum rt_object_class_type type)
void rt_object_init (struct rt_object *object, enum rt_object_class_type type, const char *name)
void rt_object_detach (rt_object_t object)
rt_object_t rt_object_allocate (enum rt_object_class_type type, const char *name)
void rt_object_delete (rt_object_t object)
rt_err_t rt_object_is_systemobject (rt_object_t object)
rt_object_t rt_object_find (const char *name, rt_uint8_t type)
void rt_system_object_init (void)
void rt_object_attach_sethook (void(*hook)(struct rt_object *object))
void rt_object_detach_sethook (void(*hook)(struct rt_object *object))
void rt_object_trytake_sethook (void(*hook)(struct rt_object *object))
void rt_object_take_sethook (void(*hook)(struct rt_object *object))
void rt_object_put_sethook (void(*hook)(struct rt_object *object))

Detailed Description

The Kernel object system can access and manage all of the kernel objects.

Kernel objects include most of the facilities in the kernel:


Define Documentation

#define RT_OBJECT_HOOK_CALL (   func,
  argv 
)    do { if ((func) != RT_NULL) func argv; } while (0)

The hook function call macro


Enumeration Type Documentation

The object type can be one of the follows with specific macros enabled:

  • Thread
  • Semaphore
  • Mutex
  • Event
  • MailBox
  • MessageQueue
  • MemPool
  • Device
  • Timer
  • Unknown
  • Static
Enumerator:
RT_Object_Class_Thread 

The object is a thread.

RT_Object_Class_Semaphore 

The object is a semaphore.

RT_Object_Class_Mutex 

The object is a mutex.

RT_Object_Class_Event 

The object is a event.

RT_Object_Class_MailBox 

The object is a mail box.

RT_Object_Class_MessageQueue 

The object is a message queue.

RT_Object_Class_MemPool 

The object is a memory pool.

RT_Object_Class_Device 

The object is a device

RT_Object_Class_Timer 

The object is a timer.

RT_Object_Class_Module 

The object is a module.

RT_Object_Class_Unknown 

The object is unknown.

RT_Object_Class_Static 

The object is a static object.


Function Documentation

This function will return the specified type of object information.

Parameters:
typethe type of object
Returns:
the object type information or RT_NULL
void rt_object_init ( struct rt_object object,
enum rt_object_class_type  type,
const char *  name 
)

This function will initialize an object and add it to object system management.

Parameters:
objectthe specified object to be initialized.
typethe object type.
namethe object name. In system, the object's name must be unique.
void rt_object_detach ( rt_object_t  object)

This function will detach a static object from object system, and the memory of static object is not freed.

Parameters:
objectthe specified object to be detached.
rt_object_t rt_object_allocate ( enum rt_object_class_type  type,
const char *  name 
)

This function will allocate an object from object system

Parameters:
typethe type of object
namethe object name. In system, the object's name must be unique.
Returns:
object
void rt_object_delete ( rt_object_t  object)

This function will delete an object and release object memory.

Parameters:
objectthe specified object to be deleted.

This function will judge the object is system object or not. Normally, the system object is a static object and the type of object set to RT_Object_Class_Static.

Parameters:
objectthe specified object to be judged.
Returns:
RT_EOK if a system object, RT_ERROR for others.
rt_object_t rt_object_find ( const char *  name,
rt_uint8_t  type 
)

This function will find specified name object from object container.

Parameters:
namethe specified name of object.
typethe type of object
Returns:
the found object or RT_NULL if there is no this object in object container.
Note:
this function shall not be invoked in interrupt status.
void rt_system_object_init ( void  )

This function will initialize system object management.

Deprecated:
since 0.3.0, this function does not need to be invoked in the system initialization.
void rt_object_attach_sethook ( void(*)(struct rt_object *object)  hook)

This function will set a hook function, which will be invoked when object attaches to kernel object system.

Parameters:
hookthe hook function
void rt_object_detach_sethook ( void(*)(struct rt_object *object)  hook)

This function will set a hook function, which will be invoked when object detaches from kernel object system.

Parameters:
hookthe hook function
void rt_object_trytake_sethook ( void(*)(struct rt_object *object)  hook)

This function will set a hook function, which will be invoked when object is taken from kernel object system.

The object is taken means: semaphore - semaphore is taken by thread mutex - mutex is taken by thread event - event is received by thread mailbox - mail is received by thread message queue - message is received by thread

Parameters:
hookthe hook function
void rt_object_take_sethook ( void(*)(struct rt_object *object)  hook)

This function will set a hook function, which will be invoked when object have been taken from kernel object system.

The object have been taken means: semaphore - semaphore have been taken by thread mutex - mutex have been taken by thread event - event have been received by thread mailbox - mail have been received by thread message queue - message have been received by thread timer - timer is started

Parameters:
hookthe hook function
void rt_object_put_sethook ( void(*)(struct rt_object *object)  hook)

This function will set a hook function, which will be invoked when object is put to kernel object system.

Parameters:
hookthe hook function
 All Data Structures Variables