Gary-Hobson opened a new pull request, #13130:
URL: https://github.com/apache/nuttx/pull/13130

   ## Summary
   This is a memory monitoring interface implemented with reference to Linux's 
PSI (Pressure Stall Information),
   which can send notifications when the system's remaining memory is below the 
threshold.
   
   The following example code sets two different thresholds.
   When the system memory is below 10MB, a notification is triggered.
   When the system memory is below 20 MB, a notification (POLLPRI event) is 
triggered every 1s.
   
   ```
   int main(int argc, FAR char *argv[])
   {
     struct pollfd fds[2];
     int ret;
   
     if (argc == 2)
       {
         char *ptr = malloc(1024*1024*atoi(argv[1]));
         printf("Allocating %d MB\n", atoi(argv[1]));
         ptr[0] = 0;
         return 0;
       }
   
     fds[0].fd = open("/proc/pressure/memory", O_RDWR);
     fds[1].fd = open("/proc/pressure/memory", O_RDWR);
     fds[0].events = POLLPRI;
     fds[1].events = POLLPRI;
   
     dprintf(fds[0].fd, "%llu -1", 1024LLU*1024 * 10);
     dprintf(fds[1].fd, "%llu 1000000", 1024LLU*1024 * 20);
   
     while (1)
       {
         ret = poll(fds, 2, -1);
         if (ret > 0)
           {
             printf("Memory pressure: POLLPRI, %d\n", ret);
           }
       }
   
     return 0;
   }
   ```
   
   https://docs.kernel.org/accounting/psi.html
   ## Impact
   
   ## Testing
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to