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