1e41f4b71Sopenharmony_ci# sem 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Command Function 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThis command is used to query information about kernel semaphores. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Syntax 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_cisem [_ID__ / fulldata_] 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## Parameters 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**Table 1** Parameter description 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| Parameter| Description| Value Range| 19e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 20e41f4b71Sopenharmony_ci| ID | Specifies the semaphore ID.| [0, 1023] or [0x0, 0x3FF]| 21e41f4b71Sopenharmony_ci| fulldata | Displays information about all semaphores in use. <br/>The displayed information includes **SemID**, **Count**, **Original Count**, **Creator TaskEntry**, and **Last Access Time**. | N/A | 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## Usage Guidelines 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci- If no parameter is specified, this command displays the semaphore IDs and the number of times that each semaphore is used. 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci- If **ID** is specified, the use of the specified semaphore is displayed. 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci- The **fulldata** parameter depends on **LOSCFG_DEBUG_SEMAPHORE**. Before using this parameter, set **Enable Semaphore Debugging** to **Yes** on **menuconfig**. 31e41f4b71Sopenharmony_ci **Debug** ---> **Enable a Debug Version** ---> **Enable Debug LiteOS Kernel Resource** ---> E**nable Semaphore Debugging** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci## Example 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci- Run **sem**. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci- Configure **LOSCFG_DEBUG_SEMAPHORE** and run **sem fulldata**. 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci## Output 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ciExample 1: brief semaphore information 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci``` 46e41f4b71Sopenharmony_ciOHOS # sem 47e41f4b71Sopenharmony_ci SemID Count 48e41f4b71Sopenharmony_ci ---------- ----- 49e41f4b71Sopenharmony_ci 0x00000000 1 50e41f4b71Sopenharmony_ci SemID Count 51e41f4b71Sopenharmony_ci ---------- ----- 52e41f4b71Sopenharmony_ci 0x00000001 0 53e41f4b71Sopenharmony_ci SemID Count 54e41f4b71Sopenharmony_ci ---------- ----- 55e41f4b71Sopenharmony_ci 0x00000002 0 56e41f4b71Sopenharmony_ci SemID Count 57e41f4b71Sopenharmony_ci ---------- ----- 58e41f4b71Sopenharmony_ci 0x00000003 1 59e41f4b71Sopenharmony_ci SemID Count 60e41f4b71Sopenharmony_ci ---------- ----- 61e41f4b71Sopenharmony_ci 0x00000004 0 62e41f4b71Sopenharmony_ci SemID Count 63e41f4b71Sopenharmony_ci ---------- ----- 64e41f4b71Sopenharmony_ci 0x00000005 1 65e41f4b71Sopenharmony_ci SemID Count 66e41f4b71Sopenharmony_ci ---------- ----- 67e41f4b71Sopenharmony_ci 0x00000006 0 68e41f4b71Sopenharmony_ci``` 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**Table 2** Output description 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci| Parameter| Description| 73e41f4b71Sopenharmony_ci| -------- | -------- | 74e41f4b71Sopenharmony_ci| SemID | Semaphore ID.| 75e41f4b71Sopenharmony_ci| Count | Number of times that the semaphore is used.| 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci> **NOTE**<br> 78e41f4b71Sopenharmony_ci> The **ID** value can be in decimal or hexadecimal format. 79e41f4b71Sopenharmony_ci> 80e41f4b71Sopenharmony_ci> When **ID** is a value within [0, 1023], semaphore information of the specified ID is displayed. If the specified semaphore is not used, a message is displayed to inform you of this case. For other values, a message is displayed indicating that the parameter is incorrect. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ciExample 2: detailed semaphore information 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci``` 85e41f4b71Sopenharmony_ciOHOS # sem fulldata 86e41f4b71Sopenharmony_ciUsed Semaphore List: 87e41f4b71Sopenharmony_ci SemID Count OriginalCount Creator(TaskEntry) LastAccessTime 88e41f4b71Sopenharmony_ci ------ ------ ------------- ------------------ -------------- 89e41f4b71Sopenharmony_ci 0xb 0x0 0x0 0x404978fc 0xa1 90e41f4b71Sopenharmony_ci 0xc 0x0 0x0 0x404978fc 0xa1 91e41f4b71Sopenharmony_ci 0xd 0x0 0x0 0x404978fc 0x12c 92e41f4b71Sopenharmony_ci 0x10 0x0 0x0 0x404978fc 0x195 93e41f4b71Sopenharmony_ci 0xf 0x0 0x0 0x404978fc 0x195 94e41f4b71Sopenharmony_ci 0x11 0x0 0x0 0x4041a998 0x1d5 95e41f4b71Sopenharmony_ci 0x15 0x0 0x0 0x404978fc 0x273 96e41f4b71Sopenharmony_ci 0x14 0x0 0x0 0x404978fc 0x273 97e41f4b71Sopenharmony_ci 0x18 0x0 0x0 0x404978fc 0x352 98e41f4b71Sopenharmony_ci 0x17 0x0 0x0 0x404978fc 0x352 99e41f4b71Sopenharmony_ci 0x16 0x0 0x0 0x404978fc 0x352 100e41f4b71Sopenharmony_ci 0x1d 0x1 0x1 0x404978fc 0x385 101e41f4b71Sopenharmony_ci 0x1e 0x1 0x1 0x404978fc 0x388 102e41f4b71Sopenharmony_ci 0x1f 0x1 0x1 0x404978fc 0x38d 103e41f4b71Sopenharmony_ci 0x20 0x1 0x1 0x404978fc 0x38f 104e41f4b71Sopenharmony_ci 0x21 0x1 0x1 0x404978fc 0x392 105e41f4b71Sopenharmony_ci 0x3d 0x1 0x1 0x404978fc 0x395 106e41f4b71Sopenharmony_ci 0x3b 0x1 0x1 0x404978fc 0x395 107e41f4b71Sopenharmony_ci 0x3c 0x1 0x1 0x404978fc 0x395 108e41f4b71Sopenharmony_ci 0x39 0x1 0x1 0x404978fc 0x395 109e41f4b71Sopenharmony_ci 0x3a 0x1 0x1 0x404978fc 0x395 110e41f4b71Sopenharmony_ci 0x33 0x1 0x1 0x404978fc 0x395 111e41f4b71Sopenharmony_ci 0x35 0x1 0x1 0x404978fc 0x395 112e41f4b71Sopenharmony_ci 0x34 0x1 0x1 0x404978fc 0x395 113e41f4b71Sopenharmony_ci 0x38 0x1 0x1 0x404978fc 0x395 114e41f4b71Sopenharmony_ci``` 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**Table 3** Output description 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci| Parameter| Description| 119e41f4b71Sopenharmony_ci| -------- | -------- | 120e41f4b71Sopenharmony_ci| SemID | Semaphore ID.| 121e41f4b71Sopenharmony_ci| Count | Number of times that the semaphore is used.| 122e41f4b71Sopenharmony_ci| OriginalCount | Original count of the semaphore.| 123e41f4b71Sopenharmony_ci| Creator | Address of the entry function of the thread used to create the semaphore.| 124e41f4b71Sopenharmony_ci| LastAccessTime | Last time when the semaphore was accessed.| 125