You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move the introduction of function parameters in markdown to
source code comments, because this part of the content is
completely repeated. We only need to keep and maintain the
comments in the code. The detailed explanation of the API
in markdown can directly refer to the comments in the code.
Try not to directly copy the definition of the structure
in the markdown document, because this part of the content
may change with the upgrade of the code. Therefore, when
the structure definition is involved in markdown, try to
indicate that it is just a code snippet. The specific
definition is still directly quoted from the source code
and the source code comments.
It is very convenient to quote structures and functions
in markdown. Just use "`" to enclose the structure name
or function name, and the generated html is a link to
its definition.
According to this principle, this patch only modifies
the documents and code comments of the kernel object model.
Other modules will be modified one by one in separate
patches later.
Signed-off-by: Chen Wang <[email protected]>
Copy file name to clipboardexpand all lines: documentation/3.kernel/basic/basic.md
+15-61
Original file line number
Diff line number
Diff line change
@@ -404,7 +404,7 @@ Derivations from object control block rt_object in the above figure includes: th
404
404
405
405
## Object Control Block
406
406
407
-
Data structure of kernel object control block:
407
+
A simple code example snippet for data structure of kernel object control block:
408
408
409
409
```c
410
410
struct rt_object
@@ -420,40 +420,12 @@ struct rt_object
420
420
};
421
421
```
422
422
423
-
Types currently supported by kernel objects are as follows:
423
+
More details about this structure, see `struct rt_object`.
424
+
425
+
Regarding types currently supported by kernel objects, see:
424
426
425
427
```c
426
428
enum rt_object_class_type
427
-
{
428
-
RT_Object_Class_Thread = 0, /* Object is thread type */
429
-
#ifdef RT_USING_SEMAPHORE
430
-
RT_Object_Class_Semaphore, /* Object is semaphore type */
431
-
#endif
432
-
#ifdef RT_USING_MUTEX
433
-
RT_Object_Class_Mutex, /* Object is mutex type */
434
-
#endif
435
-
#ifdef RT_USING_EVENT
436
-
RT_Object_Class_Event, /* Object is event type */
437
-
#endif
438
-
#ifdef RT_USING_MAILBOX
439
-
RT_Object_Class_MailBox, /* Object is mailbox type */
440
-
#endif
441
-
#ifdef RT_USING_MESSAGEQUEUE
442
-
RT_Object_Class_MessageQueue, /* Object is message queue type */
443
-
#endif
444
-
#ifdef RT_USING_MEMPOOL
445
-
RT_Object_Class_MemPool, /* Object is memory pool type */
446
-
#endif
447
-
#ifdef RT_USING_DEVICE
448
-
RT_Object_Class_Device, /* Object is device type */
449
-
#endif
450
-
RT_Object_Class_Timer, /* Object is timer type */
451
-
#ifdef RT_USING_MODULE
452
-
RT_Object_Class_Module, /* Object is module */
453
-
#endif
454
-
RT_Object_Class_Unknown, /* Object is unknown */
455
-
RT_Object_Class_Static = 0x80 /* Object is a static object */
456
-
};
457
429
```
458
430
459
431
From the above type specification, we can see that if it is a static object, the highest bit of the object type will be 1 (which is the OR operation of `RT_Object_Class_Static` and other object types and operations). Otherwise it will be dynamic object, and the maximum number of object classes that the system can accommodate is 127.
When this function is called to initialize the object, the system will place the object into the object container for management, that is, initialize some parameters of the object, and then insert the object node into the object linked list of the object container. Input parameters of the function is described in the following table:
490
-
461
+
When this function is called to initialize the object, the system will place the object into the object container for management, that is, initialize some parameters of the object, and then insert the object node into the object linked list of the object container.
| object | The object pointer that needs to be initialized must point to a specific object memory block, not a null pointer or a wild pointer. |
495
-
| type | The type of the object must be a enumeration type listed in rt_object_class_type, RT_Object_Class_Static excluded. (For static objects, or objects initialized with the rt_object_init interface, the system identifies it as an RT_Object_Class_Static type) |
496
-
| name | Name of the object. Each object can be set to a name, and the maximum length for the name is specified by RT_NAME_MAX. The system does not care if it uses ’`\0`’as a terminal symbol. |
463
+
More details about this function, see `rt_object_init()`.
Calling this interface makes a static kernel object to be detached from the kernel object container, meaning the corresponding object node is deleted from the kernel object container linked list. After the object is detached, the memory occupied by the object will not be released.
507
474
475
+
More details about this function, see `rt_object_detach()`.
476
+
508
477
### Allocate object
509
478
510
479
The above descriptions are interfaces of objects initialization and detachment, both of which are under circumstances that object-oriented memory blocks already exist. But dynamic objects can be requested when needed. The memory space is freed for other applications when not needed. To request assigning new objects, you can use the following interfaces:
When calling the above interface, the system first needs to obtain object information according to the object type (especially the size information of the object type for the system to allocate the correct size of the memory data block), and then allocate memory space corresponding to the size of the object from the memory heap. Next, to start necessary initialization for the object, and finally insert it into the object container linked list in which it is located. The input parameters for this function are described in the following table:
518
-
485
+
When calling the above interface, the system first needs to obtain object information according to the object type (especially the size information of the object type for the system to allocate the correct size of the memory data block), and then allocate memory space corresponding to the size of the object from the memory heap. Next, to start necessary initialization for the object, and finally insert it into the object container linked list in which it is located.
| type | The type of the allocated object can only be of type rt_object_class_type other than RT_Object_Class_Static. In addition, the type of object allocated through this interface is dynamic, not static. |
523
-
| name | Name of the object. Each object can be set to a name, and the maximum length for the name is specified by RT_NAME_MAX. The system does not care if it uses ’`\0`’as a terminal symbol. |
More details about this function, see `rt_object_allocate()`.
527
488
528
489
### Delete Object
529
490
@@ -533,12 +494,9 @@ For a dynamic object, when it is no longer used, you can call the following inte
533
494
void rt_object_delete(rt_object_t object);
534
495
```
535
496
536
-
When the above interface is called, the object is first detached from the object container linked list, and then the memory occupied by the object is released. The following table describes the input parameters of the function:
497
+
When the above interface is called, the object is first detached from the object container linked list, and then the memory occupied by the object is released.
537
498
538
-
539
-
|Parameter |Description |
540
-
|----------|---------------|
541
-
| object | object handle |
499
+
More details about this function, see `rt_object_delete()`.
542
500
543
501
### Identify objects
544
502
@@ -548,13 +506,9 @@ Identify whether the specified object is a system object (static kernel object).
Calling the `rt_object_is_systemobject` interface can help to identify whether an object is a system object. In RT-Thread operating system, a system object is also a static object, `RT_Object_Class_Static` bit is set to 1 on the object type identifier. Usually, objects that are initialized using the `rt_object_init()` method are system objects. The input parameters for this function are described in the following table:
552
-
553
-
Input parameter of `rt_object_is_systemobject()`
509
+
Calling the `rt_object_is_systemobject` interface can help to identify whether an object is a system object. In RT-Thread operating system, a system object is also a static object, `RT_Object_Class_Static` bit is set to 1 on the object type identifier. Usually, objects that are initialized using the `rt_object_init()` method are system objects.
554
510
555
-
|**Parameter**|Description |
556
-
|-------------|---------------|
557
-
| object | Object handle |
511
+
More details about this function, see `rt_object_is_systemobject()`.
0 commit comments