1e41f4b71Sopenharmony_ci# sem 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## 命令功能 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_cisem命令用于查询系统内核信号量相关信息。 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## 命令格式 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_cisem [_ID__ / fulldata_] 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## 参数说明 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**表1** 参数说明 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| 参数 | 参数说明 | 取值范围 | 19e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 20e41f4b71Sopenharmony_ci| ID | 信号量ID。 | [0, 1023]或[0x0, 0x3FF] | 21e41f4b71Sopenharmony_ci| fulldata | 查询所有在用的信号量信息,打印信息包括如下:SemID, Count, Original Count, Creator TaskEntry, Last Access Time。 | N/A | 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci## 使用指南 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci- 参数缺省时,显示所有的信号量的使用数及信号量总数。 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci- sem后加ID,显示对应ID信号量的使用数。 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci- 参数fulldata依赖于LOSCFG_DEBUG_SEMAPHORE,使用时通过menuconfig在配置项中开启"Enable Semaphore Debugging": 31e41f4b71Sopenharmony_ci Debug ---> Enable a Debug Version ---> Enable Debug LiteOS Kernel Resource ---> Enable Semaphore Debugging 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci## 使用实例 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci- 输入sem 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci- 配置LOSCFG_DEBUG_SEMAPHORE标志,输入 sem fulldata 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci## 输出说明 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci**示例1** 查询所有在用的信号量信息 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**表2** 输出说明 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci| 输出 | 说明 | 73e41f4b71Sopenharmony_ci| -------- | -------- | 74e41f4b71Sopenharmony_ci| SemID | 信号量ID。 | 75e41f4b71Sopenharmony_ci| Count | 信号量使用数。 | 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci>  **说明:** 78e41f4b71Sopenharmony_ci> ● sem命令的ID参数输入形式以十进制形式表示或十六进制形式表示皆可。 79e41f4b71Sopenharmony_ci> 80e41f4b71Sopenharmony_ci> ● sem命令的ID参数在[0, 1023]范围内时,返回对应ID的信号量的状态(如果对应ID的信号量未被使用则进行提示);其他取值时返回参数错误的提示。 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**示例2** 查询所有在用的信号量信息 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**表3** 输出说明 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci| 输出 | 说明 | 119e41f4b71Sopenharmony_ci| -------- | -------- | 120e41f4b71Sopenharmony_ci| SemID | 信号量ID。 | 121e41f4b71Sopenharmony_ci| Count | 信号量使用数。 | 122e41f4b71Sopenharmony_ci| OriginalCount | 信号量原始计数。 | 123e41f4b71Sopenharmony_ci| Creator | 信号量的创建线程的入口函数地址。 | 124e41f4b71Sopenharmony_ci| LastAccessTime | 上次访问时间。 | 125