1e41f4b71Sopenharmony_ci# plimits
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## Overview
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciThe complexity of app environments and growing number of processes will cause contention and waste of resources if restrictions are applied on containers. Process Limits (plimits) is a mechanism provided by the kernel to limit the resources used by a single process or multiple processes. It can implement refined control on resources such as CPUs and memory. 
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciplimitsfs is a file system that provides an interface for creating and deleting plimits. plimitsfs enables processes and process resources to be grouped for management through operations on files. Plimiters are configured to restrict the usage of resources, such as memory and sched, in process groups.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Basic Concepts
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci- plimits: a feature provided by the kernel to limit, record, and isolate the resources used by a group of processes.
12e41f4b71Sopenharmony_ci- plimitsfs: a file system, which provides an interface for users to create and delete plimits and displays the plimits directories.
13e41f4b71Sopenharmony_ci- plimiter: a collection of resource limiters. plimiter includes the memory limiter, pids limiter, and sched limiter.
14e41f4b71Sopenharmony_ci- sched limiter: limits the time to use CPUs for all processes in a plimits group in a specified period.
15e41f4b71Sopenharmony_ci- memory limiter: limits the total memory that can be used by all processes in a plimits group.
16e41f4b71Sopenharmony_ci- pids limiter: limits the maximum number of processes that can be mounted in a plimits group.
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## Working Principles
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ciDuring the system initialization process, the **plimits** directory is mounted to the **proc** directory.
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci```
23e41f4b71Sopenharmony_ci├─proc
24e41f4b71Sopenharmony_ci│  ├─plimits
25e41f4b71Sopenharmony_ci│  │  ├─plimits.plimiter_add
26e41f4b71Sopenharmony_ci│  │  ├─plimits.plimiter_delete
27e41f4b71Sopenharmony_ci│  │  ├─plimits.procs
28e41f4b71Sopenharmony_ci│  │  ├─plimits.limiters
29e41f4b71Sopenharmony_ci│  │  ├─pids.max
30e41f4b71Sopenharmony_ci│  │  ├─sched.period
31e41f4b71Sopenharmony_ci│  │  ├─sched.quota
32e41f4b71Sopenharmony_ci│  │  ├─sched.stat
33e41f4b71Sopenharmony_ci│  │  ├─memory.failcnt
34e41f4b71Sopenharmony_ci│  │  ├─memory.limit
35e41f4b71Sopenharmony_ci│  │  ├─memory.peak
36e41f4b71Sopenharmony_ci│  │  ├─memory.usage
37e41f4b71Sopenharmony_ci│  │  ├─memory.oom_ctrl
38e41f4b71Sopenharmony_ci│  │  └─memory.stat
39e41f4b71Sopenharmony_ci```
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci- plimits groups
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci  **Figure 1** Creating or deleting plimits
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci  ![](figures/create_delete_plimits.png)
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci- sched limiter
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci  **Figure 2** sched limiter configuration
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci  ![](figures/sched_limiter.png)
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci- Memory limiter
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci  **Figure 3** Memory limiter configuration
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci  ![](figures/memory_limiter.png)
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci- pids limiter
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci  **Figure 4** pids limiter configuration
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci  ![](figures/pids_limiter.png)
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci## How to Develop
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci### Available APIs
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciThe plimits root directory of LiteOS-A is in **/proc/plimits**. All files in this directory are read-only. The values setting in the limiter file are maximum values by default. You can view the status of process resources in the group from the files.
72e41f4b71Sopenharmony_ciRun the **mkdir** command to create a **plimitsA** directory to group process resources and restrict resource allocation. The created **plimitsA** directory inherits its parent **plimits** directory. 
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ciThe following table lists the files in the **plimitsA** directory.
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci| Permissions | Size| User| User Group|         File        | Description|
77e41f4b71Sopenharmony_ci| --------- | ---- | ---- | ------ | ---------------------- | --------- |
78e41f4b71Sopenharmony_ci|-r--r--r-- | 0    | u:0  | g:0    | sched.stat             | Time slice of each thread in the last period. The time slice information is used for test and verification.|
79e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | sched.quota            | Sum of time slices of all processes in a group in a period, in ns.|
80e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | sched.period           | Statistical period of the time slice, in ns.|
81e41f4b71Sopenharmony_ci|-r--r--r-- | 0    | u:0  | g:0    | memory.stat            | Memory usage statistics, in bytes.|
82e41f4b71Sopenharmony_ci|-r--r--r-- | 0    | u:0  | g:0    | memory.usage           | Memory quota used, in bytes.|
83e41f4b71Sopenharmony_ci|-r--r--r-- | 0    | u:0  | g:0    | memory.peak            | Historical peak memory usage, in bytes.|
84e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | memory.limit           | Memory usage limit, in bytes.|
85e41f4b71Sopenharmony_ci|-r--r--r-- | 0    | u:0  | g:0    | memory.failcnt         | Number of memory allocation failures when the memory usage exceeds the limit.|
86e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | pids.max               | Maximum number of processes that can be mounted to a group.|
87e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | plimits.procs          | All processes mounted to a group.|
88e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | plimits.limiter_delete | Used to delete a limiter. |
89e41f4b71Sopenharmony_ci|-rw-r--r-- | 0    | u:0  | g:0    | plimits.limiter_add    | Used to add a limiter. |
90e41f4b71Sopenharmony_ci|-r--r--r-- | 0    | u:0  | g:0    | plimits.limiters       | Used to view the limiters of a group. |
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ciAll the files in the **plimitsA** directory in **/proc/plimits/** are readable, and some are writable. You can allocate and restrict process resources by writing data to the files in the **plimitsA** directory. You can:
93e41f4b71Sopenharmony_ci- Write time, in ns, to the **sched.quota** file to limit the time for all processes in the group to use CPUs.
94e41f4b71Sopenharmony_ci- Write time, in ns, to the **sched.period** file to set the period for collecting statistics in a group.
95e41f4b71Sopenharmony_ci- Write the memory, in bytes, to the **memory.limit** file to limit the memory that can be used by a group.
96e41f4b71Sopenharmony_ci- Write a decimal number to the **pids.max** file to limit the number of processes that can be mounted to a group.
97e41f4b71Sopenharmony_ci- Write process IDs (PIDs) to the **plimits.procs** file to mount processes to different plimits groups.
98e41f4b71Sopenharmony_ci- Read files to view the resource usage configuration of a group.
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci#### Deleting the **plimitsA** Group
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ciWrite **sched**, **memory**, and **pids** to the **/proc/plimits/plimitsA/plimits.limiter_delete** file in sequence to delete the limiters, and then run the **rmdir** command to delete **plimitsA**.
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_ci|    Permissions  |   Size |  User | User Group|         File         |
105e41f4b71Sopenharmony_ci| --------- | ------- | ------ | ------ | ----------------------- |
106e41f4b71Sopenharmony_ci|-rw-r--r-- | 0       | u:0    | g:0    | plimits.procs           |
107e41f4b71Sopenharmony_ci|-rw-r--r-- | 0       | u:0    | g:0    | plimits.limiter_delete  |
108e41f4b71Sopenharmony_ci|-rw-r--r-- | 0       | u:0    | g:0    | plimits.limiter_add     |
109e41f4b71Sopenharmony_ci|-r--r--r-- | 0       | u:0    | g:0    | plimits.limiters        |
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci### How to Develop
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci1. Create **plimitsA** and write PIDs to **/plimitsA/plimits.procs** to group process resources.
114e41f4b71Sopenharmony_ci2. Write the **/plimitsA/memory.limit** file to limit the maximum memory that can be used by the **plimitsA** group.
115e41f4b71Sopenharmony_ci3. Write a decimal number to the **/plimitsA/pids.max** file to limit the number of processes that can be mounted to the **plimitsA** group.
116e41f4b71Sopenharmony_ci4. Configure the limiter files in the **plimitsA** group to allocate and limit resources. If you do not want to limit the use of resources, delete **plimitsA**.
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci### Development Example
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ciThe following example demonstrates how to create the **plimitsA** group and implement resource control of this group by reading and writing the files of **plimitsA**.
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci```
123e41f4b71Sopenharmony_ci#include <stdio.h>
124e41f4b71Sopenharmony_ci#include <unistd.h>
125e41f4b71Sopenharmony_ci#include <stdlib.h>
126e41f4b71Sopenharmony_ci#include <string.h>
127e41f4b71Sopenharmony_ci#include <sys/types.h>
128e41f4b71Sopenharmony_ci#include <sys/stat.h>
129e41f4b71Sopenharmony_ci#include <fcntl.h>
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci#define LOS_OK 0
132e41f4b71Sopenharmony_ci#define LOS_NOK -1
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ciint main ()
135e41f4b71Sopenharmony_ci{
136e41f4b71Sopenharmony_ci    int ret;
137e41f4b71Sopenharmony_ci    ssize_t len;
138e41f4b71Sopenharmony_ci    int fd = -1;
139e41f4b71Sopenharmony_ci    //get main pid
140e41f4b71Sopenharmony_ci    int mainpid = getpid();
141e41f4b71Sopenharmony_ci    char plimitsA[128] = "/proc/plimits/plimitsA";
142e41f4b71Sopenharmony_ci    char plimitsAPids[128] = "/proc/plimits/plimitsA/pids.max";
143e41f4b71Sopenharmony_ci    char plimitsAMemoryLimit[128] = "/proc/plimits/plimitsA/memory.limit";
144e41f4b71Sopenharmony_ci    char plimitsAMemoryUsage[128] = "/proc/plimits/plimitsA/memory.usage";
145e41f4b71Sopenharmony_ci    char plimitsAProcs[128] = "/proc/plimits/plimitsA/plimits.procs";
146e41f4b71Sopenharmony_ci    char plimitsAAdd[128] = "/proc/plimits/plimitsA/plimits.limiter_add";
147e41f4b71Sopenharmony_ci    char plimitsADelete[128] = "/proc/plimits/plimitsA/plimits.limiter_delete";
148e41f4b71Sopenharmony_ci    char plimitsMem[128] = "/proc/plimits/memory.usage";
149e41f4b71Sopenharmony_ci    char plimitsPid[128] = "/proc/plimits/plimits.procs";
150e41f4b71Sopenharmony_ci    char *mem = NULL;
151e41f4b71Sopenharmony_ci    char writeBuf[128];
152e41f4b71Sopenharmony_ci    char readBuf[128];
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci    /* Check the processes in the plimits group. */
155e41f4b71Sopenharmony_ci    memset(readBuf, 0, sizeof(readBuf));
156e41f4b71Sopenharmony_ci    fd = open(plimitsPid, O_RDONLY);
157e41f4b71Sopenharmony_ci    len = read(fd, readBuf, sizeof(readBuf));
158e41f4b71Sopenharmony_ci    if (len != strlen(readBuf)) {
159e41f4b71Sopenharmony_ci        printf("read file failed.\n");
160e41f4b71Sopenharmony_ci        return LOS_NOK;
161e41f4b71Sopenharmony_ci    }
162e41f4b71Sopenharmony_ci    close(fd);
163e41f4b71Sopenharmony_ci    printf ("Processes in /proc/plimits: %s\n," readBuf);
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci    /* Check the memory usage of the plimits group. */
166e41f4b71Sopenharmony_ci    memset(readBuf, 0, sizeof(readBuf));
167e41f4b71Sopenharmony_ci    fd = open(plimitsMem, O_RDONLY);
168e41f4b71Sopenharmony_ci    len = read(fd, readBuf, sizeof(readBuf));
169e41f4b71Sopenharmony_ci    if (len != strlen(readBuf)) {
170e41f4b71Sopenharmony_ci        printf("read file failed.\n");
171e41f4b71Sopenharmony_ci        return LOS_NOK;
172e41f4b71Sopenharmony_ci    }
173e41f4b71Sopenharmony_ci    close(fd);
174e41f4b71Sopenharmony_ci    printf ("Memory used in /proc/plimits: %s\n," readBuf);
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci    /* Create plimitsA "/proc/plimits/plimitsA". */
178e41f4b71Sopenharmony_ci    ret = mkdir(plimitsA, 0777);
179e41f4b71Sopenharmony_ci    if (ret != LOS_OK) {
180e41f4b71Sopenharmony_ci        printf("mkdir failed.\n");
181e41f4b71Sopenharmony_ci        return LOS_NOK;
182e41f4b71Sopenharmony_ci    }
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci    /* Set the number of processes that can be mounted to the plimitsA group. */
185e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
186e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%d", 3);
187e41f4b71Sopenharmony_ci    fd = open(plimitsAPids, O_WRONLY);
188e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
189e41f4b71Sopenharmony_ci    if (len != strlen(writeBuf)) {
190e41f4b71Sopenharmony_ci        printf("write file failed.\n");
191e41f4b71Sopenharmony_ci        return LOS_NOK;
192e41f4b71Sopenharmony_ci    }
193e41f4b71Sopenharmony_ci    close(fd);
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci    /* Mount processes to the plimitsA group. */
196e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
197e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%d", mainpid);
198e41f4b71Sopenharmony_ci    fd = open(plimitsAProcs, O_WRONLY);
199e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
200e41f4b71Sopenharmony_ci    if (len != strlen(writeBuf)) {
201e41f4b71Sopenharmony_ci        printf("write file failed.\n");
202e41f4b71Sopenharmony_ci        return LOS_NOK;
203e41f4b71Sopenharmony_ci    }
204e41f4b71Sopenharmony_ci    close(fd);
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci    /* Set the memory allocation limit in the plimitsA group. */
207e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
208e41f4b71Sopenharmony_ci    //limit memory
209e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%d", (1024*1024*3));
210e41f4b71Sopenharmony_ci    fd = open(plimitsAMemoryLimit, O_WRONLY);
211e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
212e41f4b71Sopenharmony_ci    if (len != strlen(writeBuf)) {
213e41f4b71Sopenharmony_ci        printf("write file failed.\n");
214e41f4b71Sopenharmony_ci        return LOS_NOK;
215e41f4b71Sopenharmony_ci    }
216e41f4b71Sopenharmony_ci    close(fd);
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci    /* Check the maximum memory that can be used in the plimitsA group. */
219e41f4b71Sopenharmony_ci    memset(readBuf, 0, sizeof(readBuf));
220e41f4b71Sopenharmony_ci    fd = open(plimitsAMemoryLimit, O_RDONLY);
221e41f4b71Sopenharmony_ci    len = read(fd, readBuf, sizeof(readBuf));
222e41f4b71Sopenharmony_ci    if (len != strlen(readBuf)) {
223e41f4b71Sopenharmony_ci        printf("read file failed.\n");
224e41f4b71Sopenharmony_ci        return LOS_NOK;
225e41f4b71Sopenharmony_ci    }
226e41f4b71Sopenharmony_ci    close(fd);
227e41f4b71Sopenharmony_ci    printf ("Maximum memory allowed for /proc/plimits/plimitsA: %s\n," readBuf);
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci    /* Check the processes mounted to the plimitsA group. */
230e41f4b71Sopenharmony_ci    memset(readBuf, 0, sizeof(readBuf));
231e41f4b71Sopenharmony_ci    fd = open(plimitsAProcs, O_RDONLY);
232e41f4b71Sopenharmony_ci    len = read(fd, readBuf, sizeof(readBuf));
233e41f4b71Sopenharmony_ci    if (len != strlen(readBuf)) {
234e41f4b71Sopenharmony_ci        printf("read file failed.\n");
235e41f4b71Sopenharmony_ci        return LOS_NOK;
236e41f4b71Sopenharmony_ci    }
237e41f4b71Sopenharmony_ci    close(fd);
238e41f4b71Sopenharmony_ci    printf ("Process mounted to /proc/plimits/plimitsA: %s\n," readBuf);
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci    /* Check the memory usage of the plimitsA group. */
241e41f4b71Sopenharmony_ci    mem = (char*)malloc(1024*1024);
242e41f4b71Sopenharmony_ci    memset(mem, 0, 1024);
243e41f4b71Sopenharmony_ci    memset(readBuf, 0, sizeof(readBuf));
244e41f4b71Sopenharmony_ci    fd = open(plimitsAMemoryUsage, O_RDONLY);
245e41f4b71Sopenharmony_ci    len = read(fd, readBuf, sizeof(readBuf));
246e41f4b71Sopenharmony_ci    if (len != strlen(readBuf)) {
247e41f4b71Sopenharmony_ci        printf("read file failed.\n");
248e41f4b71Sopenharmony_ci        return LOS_NOK;
249e41f4b71Sopenharmony_ci    }
250e41f4b71Sopenharmony_ci    close(fd);
251e41f4b71Sopenharmony_ci    printf ("Memory used by /proc/plimits/plimitsA: %s\n," readBuf);
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci    /* Delete the memory limiter for the plimitsA group. */
254e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
255e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%s", "memory");
256e41f4b71Sopenharmony_ci    fd = open(plimitsADelete, O_WRONLY);
257e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
258e41f4b71Sopenharmony_ci    if (len != strlen(writeBuf)) {
259e41f4b71Sopenharmony_ci        printf("write file failed.\n");
260e41f4b71Sopenharmony_ci        return LOS_NOK;
261e41f4b71Sopenharmony_ci    }
262e41f4b71Sopenharmony_ci    close(fd);
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci    /* Add a memory limiter to the plimitsA group. */
265e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
266e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%s", "memory");
267e41f4b71Sopenharmony_ci    fd = open(plimitsAAdd, O_WRONLY);
268e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
269e41f4b71Sopenharmony_ci    if (len != strlen(writeBuf)) {
270e41f4b71Sopenharmony_ci        printf("write file failed.\n");
271e41f4b71Sopenharmony_ci        return LOS_NOK;
272e41f4b71Sopenharmony_ci    }
273e41f4b71Sopenharmony_ci    close(fd);
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci    /* Delete the plimitsA group. You need to delete the memory, pids, and sched limiters first. */
276e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
277e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%s", "memory");
278e41f4b71Sopenharmony_ci    fd = open(plimitsADelete, O_WRONLY);
279e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
280e41f4b71Sopenharmony_ci    if (len != strlen(writeBuf)) {
281e41f4b71Sopenharmony_ci        printf("write file failed.\n");
282e41f4b71Sopenharmony_ci        return LOS_NOK;
283e41f4b71Sopenharmony_ci    }
284e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
285e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%s", "pids");
286e41f4b71Sopenharmony_ci    fd = open(plimitsADelete, O_WRONLY);
287e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci    memset(writeBuf, 0, sizeof(writeBuf));
290e41f4b71Sopenharmony_ci    sprintf(writeBuf, "%s", "sched");
291e41f4b71Sopenharmony_ci    fd = open(plimitsADelete, O_WRONLY);
292e41f4b71Sopenharmony_ci    len = write(fd, writeBuf, strlen(writeBuf));
293e41f4b71Sopenharmony_ci    close(fd);
294e41f4b71Sopenharmony_ci    ret = rmdir(plimitsA);
295e41f4b71Sopenharmony_ci    if (ret != LOS_OK) {
296e41f4b71Sopenharmony_ci        printf("rmdir failed.\n");
297e41f4b71Sopenharmony_ci        return LOS_NOK;
298e41f4b71Sopenharmony_ci    }
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci    return 0;
301e41f4b71Sopenharmony_ci}
302e41f4b71Sopenharmony_ci```
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci### Verification
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ciThe development is successful if the return result is as follows:
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci```
311e41f4b71Sopenharmony_ciProcesses in the /proc/plimits group:
312e41f4b71Sopenharmony_ci1
313e41f4b71Sopenharmony_ci2
314e41f4b71Sopenharmony_ci3
315e41f4b71Sopenharmony_ci4
316e41f4b71Sopenharmony_ci5
317e41f4b71Sopenharmony_ci6
318e41f4b71Sopenharmony_ci7
319e41f4b71Sopenharmony_ci8
320e41f4b71Sopenharmony_ci9
321e41f4b71Sopenharmony_ci10
322e41f4b71Sopenharmony_ci11
323e41f4b71Sopenharmony_ci12
324e41f4b71Sopenharmony_ci13
325e41f4b71Sopenharmony_ci14
326e41f4b71Sopenharmony_ci15
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ciMemory used in /proc/plimits: 28016640
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ciMaximum memory allowed for /proc/plimits/plimitsA: 3145728
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ciProcess mounted to /proc/plimits/plimitsA:
333e41f4b71Sopenharmony_ci15
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ciMemory used by /proc/plimits/plimitsA: 4096
336e41f4b71Sopenharmony_ci```
337